cmogstored.git  about / heads / tags
alternative mogstored implementation for MogileFS
blob 5a5b113b1d80c590c997fb4c884a481a746920e1 842 bytes (raw)
$ git show HEAD:test/valid-path-1.c	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
/*
 * Copyright (C) 2012-2020 all contributors <cmogstored-public@yhbt.net>
 * License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 */
#include "check.h"
#define VP(path) mog_valid_path((path), sizeof(path) - 1)
#define VPP(path) mog_valid_put_path((path), sizeof(path) - 1)

int main(void)
{
	assert(0 == VP("hello/.."));
	assert(1 == VP("hello/"));
	assert(1 == VP("hello.fid"));
	assert(0 == VP("../hello.fid"));
	assert(0 == VP("/../hello.fid"));
	assert(0 == VP("/hello.fid/.."));
	assert(0 == VP("/hello/../fid"));

	assert(VPP("/dev123/foo"));
	assert(VPP("/dev123/foo.fid"));
	assert(VPP("/dev123/0/1/2/3/4.fid"));
	assert(VPP("/dev16777215/0/000/000/0123456789.fid"));
	assert(!VPP("/dev123/foo/"));
	assert(!VPP("/dev123//"));
	assert(!VPP("///"));
	assert(!VPP("/wtf//"));
	assert(!VPP("/dev123/foo.fid/"));

	return 0;
}

git clone https://yhbt.net/cmogstored.git