Exemplo n.º 1
0
/**
 * Constructs in \a targetpath the name of a directory relative to a version-specific
 * subdirectory in the parent directory of the Blender executable.
 *
 * \param targetpath  String to return path
 * \param folder_name  Optional folder name within version-specific directory
 * \param subfolder_name  Optional subfolder name within folder_name
 * \param ver  To construct name of version-specific directory within bprogdir
 * \return true if such a directory exists.
 */
static bool get_path_local(char *targetpath, const char *folder_name, const char *subfolder_name, const int ver)
{
	char relfolder[FILE_MAX];
	
#ifdef PATH_DEBUG
	printf("%s...\n", __func__);
#endif

	if (folder_name) {
		if (subfolder_name) {
			BLI_join_dirfile(relfolder, sizeof(relfolder), folder_name, subfolder_name);
		}
		else {
			BLI_strncpy(relfolder, folder_name, sizeof(relfolder));
		}
	}
	else {
		relfolder[0] = '\0';
	}

	/* try EXECUTABLE_DIR/2.5x/folder_name - new default directory for local blender installed files */
#ifdef __APPLE__
	static char osx_resourses[FILE_MAX]; /* due new codesign situation in OSX > 10.9.5 we must move the blender_version dir with contents to Resources */
	sprintf(osx_resourses, "%s../Resources", bprogdir);
	return test_path(targetpath, osx_resourses, blender_version_decimal(ver), relfolder);
#else
	return test_path(targetpath, bprogdir, blender_version_decimal(ver), relfolder);
#endif
}
Exemplo n.º 2
0
static void test_rev(SkCanvas* canvas, const SkPath& path) {
    test_path(canvas, path);

    SkPath rev;
    rev.reverseAddPath(path);
    canvas->save();
    canvas->translate(150, 0);
    test_path(canvas, rev);
    canvas->restore();
}
Exemplo n.º 3
0
/*
 * Processes a single top-level man directory.  If section isn't NULL,
 * it will only process that section sub-directory, otherwise it will
 * process all of them.
 */
static void
process_mandir(char *dir_name, char *section)
{
	fchdir(starting_dir);
	if (already_visited(NULL, dir_name, section == NULL))
		return;
	check_writable(dir_name);
	if (verbose)
		fprintf(stderr, "man directory %s\n", dir_name);
	if (pretend)
		fprintf(stderr, "cd %s\n", dir_name);
	if (chdir(dir_name) < 0) {
		warn("%s: chdir", dir_name);
		exit_code = 1;
		return;
	}
	if (section != NULL) {
		process_section(dir_name, section);
	} else {
		struct dirent **entries;
		char *machine_dir, *arch_dir;
		int nsections;
		int i;

		nsections = scandir(".", &entries, select_sections, alphasort);
		if (nsections < 0) {
			warn("%s", dir_name);
			exit_code = 1;
			return;
		}
		for (i = 0; i < nsections; i++) {
			process_section(dir_name, entries[i]->d_name);
			asprintf(&machine_dir, "%s/%s", entries[i]->d_name,
			    machine);
			if (test_path(machine_dir, NULL) & TEST_DIR)
				process_section(dir_name, machine_dir);
			free(machine_dir);
			if (strcmp(machine_arch, machine) != 0) {
				asprintf(&arch_dir, "%s/%s", entries[i]->d_name,
				    machine_arch);
				if (test_path(arch_dir, NULL) & TEST_DIR)
					process_section(dir_name, arch_dir);
				free(arch_dir);
			}
			free(entries[i]);
		}
		free(entries);
	}
}
Exemplo n.º 4
0
static int get_path_local(char *targetpath, const char *folder_name, const char *subfolder_name, const int ver)
{
	char relfolder[FILE_MAX];
	
#ifdef PATH_DEBUG2
	printf("get_path_local...\n");
#endif

	if (folder_name) {
		if (subfolder_name) {
			BLI_join_dirfile(relfolder, sizeof(relfolder), folder_name, subfolder_name);
		}
		else {
			BLI_strncpy(relfolder, folder_name, sizeof(relfolder));
		}
	}
	else {
		relfolder[0] = '\0';
	}

	/* try EXECUTABLE_DIR/2.5x/folder_name - new default directory for local blender installed files */
	if (test_path(targetpath, bprogdir, blender_version_decimal(ver), relfolder))
		return 1;

	return 0;
}
Exemplo n.º 5
0
char	*comput_path(t_env_node *list, char *name)
{
  char	*path;
  char	**t;
  int	i;

  if ((path = find_value(list, "PATH")) == NULL)
  {
    path = search_default_path(name);
    if (path != NULL)
      return (path);
    return (my_strdup(name));
  }
  t = my_str_to_wordtab_sep(path, ':');
  free(path);
  i = 0;
  while (t[i] != NULL)
  {
    path = test_path(t[i], name);
    if (path != NULL)
      return (path);
    ++i;
  }
  clean_wordtab(t);
  if ((name[0] == '.' && name[1] == '/') || name[0] == '/')
    return (my_strdup(name));
  return (NULL);
}
Exemplo n.º 6
0
/*
 * If the directory exists, attempt to make it writable, otherwise
 * attempt to create it.
 */
static int
make_writable_dir(char *mandir, char *dir)
{
	int test;

	if ((test = test_path(dir, NULL)) != 0) {
		if (!(test & TEST_WRITABLE) && chmod(dir, 0755) < 0) {
			warn("%s/%s: chmod", mandir, dir);
			exit_code = 1;
			return 0;
		}
	} else {
		if (verbose || pretend)
			fprintf(stderr, "mkdir %s\n", dir);
		if (!pretend) {
			unlink(dir);
			if (mkdir(dir, 0755) < 0) {
				warn("%s/%s: mkdir", mandir, dir);
				exit_code = 1;
				return 0;
			}
		}
	}
	return 1;
}
Exemplo n.º 7
0
char   	*get_path(char *cmd, char *path, int *ispath, t_dlist *lenv)
{
  int	ok;
  char	*sys_path;

  ok = 1;
  path = NULL;
  sys_path = NULL;
  if ((str_noslash_and_acsok(cmd)) == 1)
    return (path);
  if (my_strlen(cmd) >= 2)
    if (cmd[0] == '/' && (access(cmd, X_OK) != 0))
      {
	*ispath = -2;
	return (path);
      }
  if ((sys_path = get_info("PATH", lenv)) == NULL)
    path = path_no_path(path, cmd, &ok);
  else
    path = test_path(cmd, path, &ok, sys_path);
  if (ok == 0)
    *ispath = 1;
  else
    path = strcatrealloc(path, cmd, my_strlen(cmd));
  return (path);
}
Exemplo n.º 8
0
std::pair<int, std::string> test_simple_path(std::ostream& strm,int argc, const char *argv[])
{
      sparse_graph_t s10(10, graph_type_t::UNDIRECTED);
     
      // fig 17.23 p 67
      s10.insert(simple_edge_t(0,1,1));
      s10.insert(simple_edge_t(0,2,1));
      s10.insert(simple_edge_t(0,6,1));
      s10.insert(simple_edge_t(0,5,1));
      s10.insert(simple_edge_t(1,2,1));
      s10.insert(simple_edge_t(2,3,1));
      s10.insert(simple_edge_t(3,4,1));
      s10.insert(simple_edge_t(5,4,1));
      s10.insert(simple_edge_t(2,4,1));
      s10.insert(simple_edge_t(4,6,1));

      s10.insert(simple_edge_t(7,8,1));
      
      s10.insert(simple_edge_t(9,10,1));
      s10.insert(simple_edge_t(9,11,1));
      s10.insert(simple_edge_t(9,12,1));
      s10.insert(simple_edge_t(11,12,1));

      std::string dn = test_path("simple_path.dot");
      s10.graphviz(dn);
      simple_edge_path_t sp(s10);
      simple_path_t p = sp(0, 5);
      ASSERT_CONDITION("there is a path from 0 to 5", p == true);
      ASSERT_CONDITION("there is a path no path from 0 to 9", sp(0,9) == false);
      return DONE;
}
Exemplo n.º 9
0
std::pair<int, std::string> test_transitive_closure_dag(std::ostream& strm,int argc, const char *argv[])
{
      std::string fn = test_path("transitive_closure_dag.dot");
      size_t size = 50;
      sparse_graph_t s10(size, graph_type_t::DIRECTED);
      
      s10.insert(simple_edge_t(0,1,1));
      s10.insert(simple_edge_t(0,2,1));
      s10.insert(simple_edge_t(0,3,1));
      s10.insert(simple_edge_t(0,5,1));
      s10.insert(simple_edge_t(0,6,1));
      s10.insert(simple_edge_t(2,3,1));
      s10.insert(simple_edge_t(3,4,1));
      s10.insert(simple_edge_t(3,5,1));
      s10.insert(simple_edge_t(4,9,1));
      s10.insert(simple_edge_t(6,4,1));
      s10.insert(simple_edge_t(6,9,1));
      s10.insert(simple_edge_t(7,6,1));
      s10.insert(simple_edge_t(8,7,1));
      s10.insert(simple_edge_t(9,10,1));
      s10.insert(simple_edge_t(9,11,1));
      s10.insert(simple_edge_t(9,12,1));
      s10.insert(simple_edge_t(11,12,1));
      
      is_dag<simple_edge_t> is_dag(s10);
      ASSERT_CONDITION("graph is a DAG", is_dag());
      
      s10.graphviz(fn);
      transitive_closure<sparse_graph_t, tc_dag<simple_edge_t>> tc(s10);
      std::string wts = test_path("transitive_closure_dag_results.dot");
      (*tc).graphviz(wts);
      ASSERT(tc(simple_edge_t(0,1,1)));
      ASSERT(tc(simple_edge_t(0,12,1)))
      ASSERT(tc(simple_edge_t(0,11,1)));
      ASSERT(tc(simple_edge_t(8,12,1)))
      
      ASSERT(tc(simple_edge_t(0,10,1)));
      ASSERT(tc(simple_edge_t(3,4,1)))
      ASSERT(!tc(simple_edge_t(1,4,1)));
      ASSERT(!tc(simple_edge_t(4,1,1)))
      
      ASSERT(tc(simple_edge_t(0,2,1)));
      ASSERT(!tc(simple_edge_t(2,0,1)))
      ASSERT(tc(simple_edge_t(2,4,1)));
      
      return DONE;
}
Exemplo n.º 10
0
Arquivo: env.c Projeto: eigengrau/lean
int main() {
    test_add_univ();
    test_id();
    test_path();
    test_import();
    test_inductive();
    return 0;
}
Exemplo n.º 11
0
std::pair<int, std::string> test_transitive_closure_warshall(std::ostream& strm,int argc, const char *argv[])
{
      
      size_t size = 50;
      sparse_graph_t s10(size, graph_type_t::DIRECTED);
      
      s10.insert(simple_edge_t(0,5,1));
      s10.insert(simple_edge_t(0,2,1));
      s10.insert(simple_edge_t(2,1,1));
      s10.insert(simple_edge_t(1,0,1));
      s10.insert(simple_edge_t(5,4,1));
      s10.insert(simple_edge_t(4,5,1));
      s10.insert(simple_edge_t(3,4,1));
      s10.insert(simple_edge_t(3,2,1));
      
      std::string dn = test_path("transitive_closure_graph_warshall.dot");
      s10.graphviz(dn);

      transitive_closure<sparse_graph_t, tc_warshall<simple_edge_t>> tc(s10);
      std::string wts = test_path("transitive_closure_graph_warshall_result.dot");

      (*tc).graphviz(wts);

      
      ASSERT(tc(simple_edge_t(1,2,1)));
      ASSERT(tc(simple_edge_t(2,1,1)))
      ASSERT(!tc(simple_edge_t(2,3,1)));
      ASSERT(tc(simple_edge_t(3,2,1)))
      
      ASSERT(tc(simple_edge_t(0,5,1)));
      ASSERT(tc(simple_edge_t(5,4,1)))
      ASSERT(tc(simple_edge_t(1,4,1)));
      ASSERT(!tc(simple_edge_t(4,1,1)))
      
      ASSERT(tc(simple_edge_t(0,2,1)));
      ASSERT(tc(simple_edge_t(2,0,1)))
      ASSERT(tc(simple_edge_t(2,4,1)));
      
      
      return DONE;
}
Exemplo n.º 12
0
static int get_path_user(char *targetpath, const char *folder_name, const char *subfolder_name, const char *envvar, const int ver)
{
	char user_path[FILE_MAX];
	const char *user_base_path;

	/* for portable install, user path is always local */
	if (is_portable_install())
		return get_path_local(targetpath, folder_name, subfolder_name, ver);
	
	user_path[0] = '\0';

	if (test_env_path(user_path, envvar)) {
		if (subfolder_name) {
			return test_path(targetpath, user_path, NULL, subfolder_name);
		}
		else {
			BLI_strncpy(targetpath, user_path, FILE_MAX);
			return 1;
		}
	}

	user_base_path = (const char *)GHOST_getUserDir(ver, blender_version_decimal(ver));
	if (user_base_path)
		BLI_strncpy(user_path, user_base_path, FILE_MAX);

	if (!user_path[0])
		return 0;
	
#ifdef PATH_DEBUG2
	printf("get_path_user: %s\n", user_path);
#endif
	
	if (subfolder_name) {
		/* try $HOME/folder_name/subfolder_name */
		return test_path(targetpath, user_path, folder_name, subfolder_name);
	}
	else {
		/* try $HOME/folder_name */
		return test_path(targetpath, user_path, NULL, folder_name);
	}
}
Exemplo n.º 13
0
int main(int argc , char ** argv) {
#ifdef ERT_LINUX
  const char * root1 = "/tmp/root/path";
  const char * path1 = "/tmp/root/path/relative";
  const char * true1 = "relative";

  const char * root2 = "/tmp/root/path/";
  const char * path2 = "/tmp/root/path/relative";
  const char * true2 = "relative";

  const char * root3 = "/tmp/root/path";
  const char * path3 = "/tmp/root/";
  const char * true3 = "../";
  
  const char * root4 = "/tmp/root/path";
  const char * path4 = "relative";
  const char * true4 = "relative";

  const char * root5 = "/tmp/root/path";
  const char * path5 = "/tmp/root/pathX/relative";
  const char * true5 = "../pathX/relative";

  const char * root6 = "/tmp/root/path";
  const char * path6 = "/tmpX/root/pathX/relative";
  const char * true6 = "../../../tmpX/root/pathX/relative";
  
  const char * root7 = "/tmp/root/path";
  const char * path7 = "/tmp/root/path";
  const char * true7 = NULL;

  const char * root8 = "/tmp";
  const char * path8 = "root/path";
  const char * true8 = "root/path";

#endif
  
  test_path( 1 , root1 , path1 , true1 );
  test_path( 2 , root2 , path2 , true2 );
  test_path( 3 , root3 , path3 , true3 );
  test_path( 4 , root4 , path4 , true4 );
  test_path( 5 , root5 , path5 , true5 );
  test_path( 6 , root6 , path6 , true6 );
  test_path( 7 , root7 , path7 , true7 );
  {
    chdir(root8);
    test_path( 8 , NULL , path8 , true8 );
  }

  exit(0);
}
Exemplo n.º 14
0
int main( int argc , char ** argv) {
#ifdef ERT_LINUX
  
  test_path("/tmp/" , "/tmp" );
  test_path("/tmp/test/normal" , "/tmp/test/normal" );
  test_path("/tmp/test/../test/normal" , "/tmp/test/normal");
  test_path("/tmp/test/../../tmp/test/normal" , "/tmp/test/normal");
  test_path("/tmp/test/../../tmp//test/normal" , "/tmp/test/normal");
  test_path("/tmp/test/../../tmp/./test/normal" , "/tmp/test/normal");
  test_path("/tmp/test/../../tmp/./test/normal/" , "/tmp/test/normal");
  test_path("/tmp/test/../../tmp/other/XX/" , "/tmp/other/XX");
  
#endif
  
  exit(0);
}
Exemplo n.º 15
0
int main() {
  for (int i = 0; i < 1000; ++i) {
    test(std::chrono::seconds(rand()));
  }
  test_path("");
  test_path(boost::filesystem::path());
  test_path("ssas/sasas");
  test_path("dnjasdnskdnasd//dsad");
  test_path("//");
  test_path("/sas//sa");
}
Exemplo n.º 16
0
/**
   Main test 
*/
int main( int argc, char **argv )
{
	setlocale( LC_ALL, "" );
	srand( time( 0 ) );

	program_name=L"(ignore)";
	
	say( L"Testing low-level functionality");
	say( L"Lines beginning with '(ignore):' are not errors, they are warning messages\ngenerated by the fish parser library when given broken input, and can be\nignored. All actual errors begin with 'Error:'." );

	proc_init();	
	halloc_util_init();
	event_init();	
	parser_init();
	function_init();
	builtin_init();
	reader_init();
	env_init();

	test_util();
	test_escape();
	test_convert();
	test_tok();
	test_parser();
	test_expand();
	test_path();
	
	say( L"Encountered %d errors in low-level tests", err_count );

	/*
	  Skip performance tests for now, since they seem to hang when running from inside make (?)
	*/
//	say( L"Testing performance" );
//	perf_complete();
		
	env_destroy();
	reader_destroy();	
	parser_destroy();
	function_destroy();
	builtin_destroy();
	wutil_destroy();
	event_destroy();
	proc_destroy();
	halloc_util_destroy();
	
}
Exemplo n.º 17
0
int main(int argc, char* argv[])
{
    printf("testing taa_path...");
    fflush(stdout);
    test_path();
    printf("pass\n");

#if defined(_DEBUG) && defined(_MSC_FULL_VER)
    _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
    _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT);
    _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
    _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
    _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
    _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT);
    _CrtCheckMemory();
    _CrtDumpMemoryLeaks();
#endif
    return EXIT_SUCCESS;
}
Exemplo n.º 18
0
bool PionPlugin::checkForFile(std::string& final_path, const std::string& start_path,
							  const std::string& name, const std::string& extension)
{
	// check for cygwin path oddities
	boost::filesystem::path cygwin_safe_path(start_path);
	checkCygwinPath(cygwin_safe_path, start_path);
	boost::filesystem::path test_path(cygwin_safe_path);

	// if a name is specified, append it to the test path
	if (! name.empty())
		test_path /= name;

	// check for existence of file (without extension)
	if (boost::filesystem::is_regular(test_path)) {
		final_path = test_path.file_string();
		return true;
	}
		
	// next, try appending the extension
	if (name.empty()) {
		// no "name" specified -> append it directly to start_path
		test_path = boost::filesystem::path(start_path + extension);
		// in this case, we need to re-check for the cygwin oddities
		checkCygwinPath(test_path, start_path + extension);
	} else {
		// name is specified, so we can just re-use cygwin_safe_path
		test_path = cygwin_safe_path /
			boost::filesystem::path(name + extension);
	}

	// re-check for existence of file (after adding extension)
	if (boost::filesystem::is_regular(test_path)) {
		final_path = test_path.file_string();
		return true;
	}
	
	// no plug-in file found
	return false;
}
Exemplo n.º 19
0
std::pair<int, std::string> test_transitive_closure_kernel_dag(std::ostream& strm,int argc, const char *argv[])
{
      
      size_t size = 50;
      sparse_graph_t s10(size, graph_type_t::DIRECTED);
      
      s10.insert(simple_edge_t(0,5,1));
      s10.insert(simple_edge_t(0,2,1));
      s10.insert(simple_edge_t(2,1,1));
      s10.insert(simple_edge_t(1,0,1));
      s10.insert(simple_edge_t(5,4,1));
      s10.insert(simple_edge_t(4,5,1));
      s10.insert(simple_edge_t(3,4,1));
      s10.insert(simple_edge_t(3,2,1));
      
      std::string dn = test_path("transitive_closure_kernel_dag.dot");
      s10.graphviz(dn);
      
      tc_kernel_dag<simple_edge_t> tc(s10);
      //tc.pp(strm);
      
      ASSERT(tc(simple_edge_t(1,2,1)));
      ASSERT(tc(simple_edge_t(2,1,1)))
      ASSERT(!tc(simple_edge_t(2,3,1)));
      ASSERT(tc(simple_edge_t(3,2,1)))
      
      ASSERT(tc(simple_edge_t(0,5,1)));
      ASSERT(tc(simple_edge_t(5,4,1)))
      ASSERT(tc(simple_edge_t(1,4,1)));
      ASSERT(!tc(simple_edge_t(4,1,1)))
      
      ASSERT(tc(simple_edge_t(0,2,1)));
      ASSERT(tc(simple_edge_t(2,0,1)))
      ASSERT(tc(simple_edge_t(2,4,1)));
      
      
      return DONE;
}
Exemplo n.º 20
0
DEF_TEST(ColorSpaceParseICCProfiles, r) {

#if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 6)
    test_path(r, "images/color_wheel_with_profile.png", g_sRGB_R, g_sRGB_G, g_sRGB_B, true);
#endif

    const float red[]   = { 0.385117f, 0.716904f, 0.0970612f };
    const float green[] = { 0.143051f, 0.0606079f, 0.713913f };
    const float blue[]  = { 0.436035f, 0.222488f, 0.013916f };
    test_path(r, "images/icc-v2-gbr.jpg", red, green, blue);

    test_path(r, "images/webp-color-profile-crash.webp",
            red, green, blue);
    test_path(r, "images/webp-color-profile-lossless.webp",
            red, green, blue);
    test_path(r, "images/webp-color-profile-lossy.webp",
            red, green, blue);
    test_path(r, "images/webp-color-profile-lossy-alpha.webp",
            red, green, blue);
}
Exemplo n.º 21
0
int main(int argc, char *argv[]) {

  char read_only = 0;
  char new_dbfile = 0;
  char autostarted = 0;

  unsigned long timeout = 0;
  unsigned long output_mins = 0;
  unsigned long past = 0;
  unsigned long out_delay = 0;

  char cntr;
  printf("Sleepwatch version 0.1, Copyright (C) 2016 Philip Manke\n"
         "Gnomovision comes with ABSOLUTELY NO WARRANTY; for details\n"
         "type 'sleepwatch -g'.  This is free software, and you are welcome\n"
         "to redistribute it under certain conditions;\n"
         "read the file 'COPYING' for details.\n\n");
  for (cntr = 1; cntr < argc; cntr++) {
    if (argv[cntr][0] == '-') {
      switch (argv[cntr][1]) {
      case 'a': {
        autostarted = 1;
      } break;
      case 'd': {
        if (argv[cntr][2] == '=') {
          dbfile = (char *)calloc(strlen(&argv[cntr][3]) + 1, sizeof(char));
          strncpy(dbfile, &argv[cntr][3], strlen(&argv[cntr][3]));
        } else {
          printf("Unknown argument: %s !\n", argv[cntr]);
          return 1;
        }
      } break;
      case 'f': {
        if (argv[cntr][2] == '=') {
          output = (char *)calloc(strlen(&argv[cntr][3]) + 1, sizeof(char));
          strncpy(output, &argv[cntr][3], strlen(&argv[cntr][3]));
        } else {
          printf("Unknown argument: %s !\n", argv[cntr]);
          return 1;
        }
      } break;
      case 'g': {
        printf("NO WARRANTY\n\n"
               "11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS "
               "NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY "
               "APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE "
               "COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "
               "\"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR "
               "IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES "
               "OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE "
               "ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM "
               "IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME "
               "THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n"
               "12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO "
               "IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO "
               "MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, "
               "BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, "
               "INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR "
               "INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO "
               "LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES "
               "SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM "
               "TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR "
               "OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH "
               "DAMAGES.\n");
      } break;
      case 'n': {
        new_dbfile = 1;
        printf("Starting new database.\n");
      } break;
      case 'l': {
        if (argv[cntr][2] == '=') {
          logfile = (char *)calloc(strlen(&argv[cntr][3]) + 1, sizeof(char));
          strncpy(logfile, &argv[cntr][3], strlen(&argv[cntr][3]));
        } else {
          printf("Unknown argument: %s !\n", argv[cntr]);
          return 1;
        }
      } break;
      case 'o': {
        if (argv[cntr][2] == '=') {
          output_mins = strtoul(&argv[cntr][3], NULL, 0);
        } else {
          printf("Unknown argument: %s !\n", argv[cntr]);
          return 1;
        }
      } break;
      case 'p': {
        if (argv[cntr][2] == '=') {
          past = strtoul(&argv[cntr][3], NULL, 0);
        } else {
          printf("Unknown argument: %s !\n", argv[cntr]);
          return 1;
        }
      } break;
      case 'r': {
        read_only = 1;
        printf("Only outputting data. Monitoring disabled.\n");
      } break;
      case 't': {
        if (argv[cntr][2] == '=') {
          timeout = strtoul(&argv[cntr][3], NULL, 0);
          printf("Timeout enabled. Shutting down after %lu minutes...\n",
                 timeout);
        } else {
          printf("Unknown argument: %s !\n", argv[cntr]);
          return 1;
        }
      } break;
      case 'w': {
        if (argv[cntr][2] == '=') {
          out_delay = strtoul(&argv[cntr][3], NULL, 0);
        } else {
          printf("Unknown argument: %s !\n", argv[cntr]);
          return 1;
        }
      } break;
      default: {
        printf("Unknown option: %c !\n", argv[cntr][1]);
        print_usage();
        return 1;
      } break;
      }
    } else {
      printf("Unknown argument: %s !\n", argv[cntr]);
      print_usage();
      return 1;
    }
  }

  // check file paths or set defaults
  // output file
  if (output == NULL) {
    output = (char *)calloc(strlen(DEFAULT_OUTPUT) + 1, sizeof(char));
    strncpy(output, DEFAULT_OUTPUT, strlen(DEFAULT_OUTPUT));
  }
  if (test_path(output) == 1) {
    printf(
        "ERROR! Path for output file not valid or insufficient permissions!");
    cleanup();
    return 1;
  } else {
    remove(output);
  }

  // database file
  if (dbfile == NULL) {
    dbfile = (char *)calloc(strlen(DEFAULT_DB) + 1, sizeof(char));
    strncpy(dbfile, DEFAULT_DB, strlen(DEFAULT_DB));
  }
  int ret = test_path(dbfile);
  if (ret == 1) {
    printf(
        "ERROR! Path for database file not valid or insufficient permissions!");
    cleanup();
    return 1;
  }
  if (ret == 2) {
    new_dbfile = 1;
  }

  // log file
  if (logfile == NULL) {
    logfile = (char *)calloc(strlen(DEFAULT_LOG) + 1, sizeof(char));
    strncpy(logfile, DEFAULT_LOG, strlen(DEFAULT_LOG));
  }
  if (test_path(logfile) == 1) {
    printf("ERROR! Path for log file not valid or insufficient permissions!");
    cleanup();
    return 1;
  }

  // set output fimeframe default
  if (output_mins == 0) {
    output_mins = DEFAULT_OUTPUT_MINS;
  }

  // sets output update delay default
  if (out_delay == 0) {
    out_delay = DEFAULT_OUT_DELAY;
  }
  out_delay *= 1000;

  // convert timeout from minutes to unit of 100 milliseconds if set
  if (timeout) {
    timeout *= 600;
  }

  unsigned int to = (unsigned int)past;
  unsigned int from = (unsigned int)(past + output_mins);

  // initialize the modules
  printf("Initializing...\n");
  init_log(logfile);
  if (new_dbfile) {
    remove(dbfile);
  }
  init_db(dbfile, new_dbfile);
  init_watch(!read_only);
  init_out(output, out_delay, &from, &to, read_only);
  printf("Running... ");
  if (!read_only) {
    char running = 1;

    OTHR *thread = (OTHR *)malloc(sizeof(OTHR));
    pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
    thread->spinlock = &mutex;

    if (!autostarted) {
      // start thread to check for user input
      start_other_thread(thread, 0, &check_q);
    }
    // main loop
    printf("Press 'Q'-Enter to stop!\n");
    while (running) {
      if (!autostarted) {
        pthread_mutex_lock(thread->spinlock);
        running = thread->running;
        pthread_mutex_unlock(thread->spinlock);
      }
      sleep_milliseconds(100);

      if (timeout > 0) {
        timeout--;
        if (timeout == 0) {
          printf("Timeout! Stopping...\n");
          logm("Timeout hit! Stopping...\n");
          if (!autostarted) {
            pthread_cancel(thread->t_id);
          }
          running = 0;
        }
      }
    }

    free(thread);
    pthread_mutex_destroy(&mutex);

  } else {
    printf("\n");
    refresh_out_time();
  }
  cleanup();
  return 0;
}
DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) {
    GrContext* ctx = ctxInfo.grContext();
    sk_sp<GrRenderTargetContext> rtc(ctx->makeDeferredRenderTargetContext(
            SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig, nullptr, 1, GrMipMapped::kNo,
            kTopLeft_GrSurfaceOrigin));
    if (!rtc) {
        return;
    }

    ctx->flush();
    // Adding discard to appease vulkan validation warning about loading uninitialized data on draw
    rtc->discard();

    test_path(ctx, rtc.get(), create_path_0());
    test_path(ctx, rtc.get(), create_path_1());
    test_path(ctx, rtc.get(), create_path_2());
    test_path(ctx, rtc.get(), create_path_3());
    test_path(ctx, rtc.get(), create_path_4());
    test_path(ctx, rtc.get(), create_path_5());
    test_path(ctx, rtc.get(), create_path_6());
    test_path(ctx, rtc.get(), create_path_7());
    test_path(ctx, rtc.get(), create_path_8());
    test_path(ctx, rtc.get(), create_path_9());
    test_path(ctx, rtc.get(), create_path_10());
    test_path(ctx, rtc.get(), create_path_11());
    test_path(ctx, rtc.get(), create_path_12());
    test_path(ctx, rtc.get(), create_path_13());
    test_path(ctx, rtc.get(), create_path_14());
    test_path(ctx, rtc.get(), create_path_15());
    test_path(ctx, rtc.get(), create_path_16());
    SkMatrix nonInvertibleMatrix = SkMatrix::MakeScale(0, 0);
    std::unique_ptr<GrFragmentProcessor> fp(create_linear_gradient_processor(ctx));
    test_path(ctx, rtc.get(), create_path_17(), nonInvertibleMatrix, GrAAType::kCoverage,
              std::move(fp));
    test_path(ctx, rtc.get(), create_path_18());
    test_path(ctx, rtc.get(), create_path_19());
    test_path(ctx, rtc.get(), create_path_20(), SkMatrix(), GrAAType::kCoverage);
    test_path(ctx, rtc.get(), create_path_21(), SkMatrix(), GrAAType::kCoverage);
    test_path(ctx, rtc.get(), create_path_22());
    test_path(ctx, rtc.get(), create_path_23());
    test_path(ctx, rtc.get(), create_path_24());
    test_path(ctx, rtc.get(), create_path_25(), SkMatrix(), GrAAType::kCoverage);
    test_path(ctx, rtc.get(), create_path_26(), SkMatrix(), GrAAType::kCoverage);
    test_path(ctx, rtc.get(), create_path_27(), SkMatrix(), GrAAType::kCoverage);
    test_path(ctx, rtc.get(), create_path_28(), SkMatrix(), GrAAType::kCoverage);
    test_path(ctx, rtc.get(), create_path_29());
}
Exemplo n.º 23
0
/*
 * Scan the man section directory for pages and process each one,
 * then check for junk in the corresponding cat section.
 */
static void
scan_section(char *mandir, char *section, char *cat_section)
{
	struct dirent **entries;
	char **expected = NULL;
	int npages;
	int nexpected = 0;
	int i, e;
	enum Ziptype zipped;
	char *page_name;
	char page_path[MAXPATHLEN];
	char cat_path[MAXPATHLEN];
	char zip_path[MAXPATHLEN];

	/*
	 * scan the man section directory for pages
	 */
	npages = scandir(section, &entries, NULL, alphasort);
	if (npages < 0) {
		warn("%s/%s", mandir, section);
		exit_code = 1;
		return;
	}
	if (verbose || rm_junk) {
		/*
		 * Maintain a list of all cat pages that should exist,
		 * corresponding to existing man pages.
		 */
		expected = (char **) calloc(npages, sizeof(char *));
	}
	for (i = 0; i < npages; free(entries[i++])) {
		page_name = entries[i]->d_name;
		snprintf(page_path, sizeof page_path, "%s/%s", section,
		    page_name);
		if (!is_manpage_name(page_name)) {
			if (!(test_path(page_path, NULL) & TEST_DIR)) {
				junk(mandir, page_path,
				    "invalid man page name");
			}
			continue;
		}
		zipped = is_bzipped(page_name) ? BZIP :
		    is_gzipped(page_name) ? GZIP : NONE;
		if (zipped != NONE) {
			snprintf(cat_path, sizeof cat_path, "%s/%s",
			    cat_section, page_name);
			if (expected != NULL)
				expected[nexpected++] = strdup(page_name);
			process_page(mandir, page_path, cat_path, zipped);
		} else {
			/*
			 * We've got an uncompressed man page,
			 * check to see if there's a (preferred)
			 * compressed one.
			 */
			snprintf(zip_path, sizeof zip_path, "%s%s",
			    page_path, GZ_EXT);
			if (test_path(zip_path, NULL) != 0) {
				junk(mandir, page_path,
				    "man page unused due to existing " GZ_EXT);
			} else {
				if (verbose) {
					fprintf(stderr,
						"warning, %s is uncompressed\n",
						page_path);
				}
				snprintf(cat_path, sizeof cat_path, "%s/%s",
				    cat_section, page_name);
				if (expected != NULL) {
					asprintf(&expected[nexpected++],
					    "%s", page_name);
				}
				process_page(mandir, page_path, cat_path, NONE);
			}
		}
	}
	free(entries);
	if (expected == NULL)
	    return;
	/*
	 * scan cat sections for junk
	 */
	npages = scandir(cat_section, &entries, NULL, alphasort);
	e = 0;
	for (i = 0; i < npages; free(entries[i++])) {
		const char *junk_reason;
		int cmp = 1;

		page_name = entries[i]->d_name;
		if (strcmp(page_name, ".") == 0 || strcmp(page_name, "..") == 0)
			continue;
		/*
		 * Keep the index into the expected cat page list
		 * ahead of the name we've found.
		 */
		while (e < nexpected &&
		    (cmp = strcmp(page_name, expected[e])) > 0)
			free(expected[e++]);
		if (cmp == 0)
			continue;
		/* we have an unexpected page */
		snprintf(cat_path, sizeof cat_path, "%s/%s", cat_section,
		    page_name);
		if (!is_manpage_name(page_name)) {
			if (test_path(cat_path, NULL) & TEST_DIR)
				continue;
			junk_reason = "invalid cat page name";
		} else if (!is_gzipped(page_name) && e + 1 < nexpected &&
		    strncmp(page_name, expected[e + 1], strlen(page_name)) == 0 &&
		    strlen(expected[e + 1]) == strlen(page_name) + 3) {
			junk_reason = "cat page unused due to existing " GZ_EXT;
		} else
			junk_reason = "cat page without man page";
		junk(mandir, cat_path, junk_reason);
	}
	free(entries);
	while (e < nexpected)
		free(expected[e++]);
	free(expected);
}
Exemplo n.º 24
0
/*
 * Processes a single man page source by using nroff to create
 * the preformatted cat page.
 */
static void
process_page(char *mandir, char *src, char *cat, enum Ziptype zipped)
{
	int src_test, cat_test;
	time_t src_mtime, cat_mtime;
	char cmd[MAXPATHLEN];
	dev_t src_dev;
	ino_t src_ino;
	const char *link_name;

	src_test = test_path(src, &src_mtime);
	if (!(src_test & (TEST_FILE|TEST_READABLE))) {
		if (!(src_test & TEST_DIR)) {
			warnx("%s/%s: unreadable", mandir, src);
			exit_code = 1;
			if (rm_junk && is_symlink(src))
				junk(mandir, src, "bogus symlink");
		}
		return;
	}
	src_dev = test_st.st_dev;
	src_ino = test_st.st_ino;
	cat_test = test_path(cat, &cat_mtime);
	if (cat_test & (TEST_FILE|TEST_READABLE)) {
		if (!force && cat_mtime >= src_mtime) {
			if (verbose) {
				fprintf(stderr, "\t%s/%s: up to date\n",
				    mandir, src);
			}
			return;
		}
	}
	/*
	 * Is the man page a link to one we've already processed?
	 */
	if ((link_name = find_hashtable(links, src_ino, src_dev)) != NULL) {
		if (verbose || pretend) {
			fprintf(stderr, "%slink %s -> %s\n",
			    verbose ? "\t" : "", cat, link_name);
		}
		if (!pretend)
			link(link_name, cat);
		return;
	}
	insert_hashtable(links, src_ino, src_dev, strdup(cat));
	if (verbose || pretend) {
		fprintf(stderr, "%sformat %s -> %s\n",
		    verbose ? "\t" : "", src, cat);
		if (pretend)
			return;
	}
	snprintf(tmp_file, sizeof tmp_file, "%s.tmp", cat);
	snprintf(cmd, sizeof cmd,
	    "%scat %s | tbl | nroff -c -T%s -man | %s > %s.tmp",
	    zipped == BZIP ? BZ2CAT_CMD : zipped == GZIP ? GZCAT_CMD : "",
	    src, nroff_device,
	    zipped == BZIP ? BZ2_CMD : zipped == GZIP ? GZ_CMD : "cat",
	    cat);
	if (system(cmd) != 0)
		err(1, "formatting pipeline");
	if (rename(tmp_file, cat) < 0)
		warn("%s", cat);
	tmp_file[0] = '\0';
}
Exemplo n.º 25
0
/*
 * Tests to see if the given directory can be written to.
 */
static void
check_writable(char *mandir)
{
	if (verbose && !(test_path(mandir, NULL) & TEST_WRITABLE))
		fprintf(stderr, "%s: not writable - will only be able to write to existing cat directories\n", mandir);
}
Exemplo n.º 26
0
static int get_path_system(char *targetpath, const char *folder_name, const char *subfolder_name, const char *envvar, const int ver)
{
	char system_path[FILE_MAX];
	const char *system_base_path;


	/* first allow developer only overrides to the system path
	 * these are only used when running blender from source */
	char cwd[FILE_MAX];
	char relfolder[FILE_MAX];

	if (folder_name) {
		if (subfolder_name) {
			BLI_join_dirfile(relfolder, sizeof(relfolder), folder_name, subfolder_name);
		}
		else {
			BLI_strncpy(relfolder, folder_name, sizeof(relfolder));
		}
	}
	else {
		relfolder[0] = '\0';
	}

	/* try CWD/release/folder_name */
	if (BLI_current_working_dir(cwd, sizeof(cwd))) {
		if (test_path(targetpath, cwd, "release", relfolder)) {
			return 1;
		}
	}

	/* try EXECUTABLE_DIR/release/folder_name */
	if (test_path(targetpath, bprogdir, "release", relfolder))
		return 1;
	/* end developer overrides */



	system_path[0] = '\0';

	if (test_env_path(system_path, envvar)) {
		if (subfolder_name) {
			return test_path(targetpath, system_path, NULL, subfolder_name);
		}
		else {
			BLI_strncpy(targetpath, system_path, FILE_MAX);
			return 1;
		}
	}

	system_base_path = (const char *)GHOST_getSystemDir(ver, blender_version_decimal(ver));
	if (system_base_path)
		BLI_strncpy(system_path, system_base_path, FILE_MAX);
	
	if (!system_path[0])
		return 0;
	
#ifdef PATH_DEBUG2
	printf("get_path_system: %s\n", system_path);
#endif
	
	if (subfolder_name) {
		/* try $BLENDERPATH/folder_name/subfolder_name */
		return test_path(targetpath, system_path, folder_name, subfolder_name);
	}
	else {
		/* try $BLENDERPATH/folder_name */
		return test_path(targetpath, system_path, NULL, folder_name);
	}
}
Exemplo n.º 27
0
namespace jsonv_test
{

TEST(merge_single)
{
    jsonv::value x = jsonv::merge(jsonv::null);
    ensure_eq(jsonv::null, x);
}

template <typename TMergeRules>
class json_merge_test :
        public unit_test
{
public:
    json_merge_test(const std::string& test_name,
                    jsonv::value       a,
                    jsonv::value       b,
                    jsonv::value       expected
                   ) :
            unit_test(std::string("merge_test/") + test_name),
            a(std::move(a)),
            b(std::move(b)),
            expected(std::move(expected))
    { }
    
    virtual void run_impl() override
    {
        bool expect_failure = expected.kind() == jsonv::kind::string && expected.as_string() == "FAILURE";
        
        try
        {
            TMergeRules rules;
            jsonv::value result = jsonv::merge_explicit(rules, jsonv::path(), a, b);
            ensure(!expect_failure);
            ensure_eq(expected, result);
        }
        catch (...)
        {
            if (!expect_failure)
                throw;
        }
    }
    
private:
    jsonv::value a;
    jsonv::value b;
    jsonv::value expected;
};

class json_merge_test_initializer
{
public:
    explicit json_merge_test_initializer(const std::string& rootpath)
    {
        recursive_directory_for_each(rootpath, ".json", [this] (const std::string& p)
        {
            jsonv::value whole = [&p] { std::ifstream in(p.c_str()); return jsonv::parse(in); }();
            jsonv::value a = whole.at("a");
            jsonv::value b = whole.at("b");
            
            checked_add<jsonv::throwing_merge_rules>(p, "expected", whole, a, b);
            checked_add<jsonv::recursive_merge_rules>(p, "recursive", whole, a, b);
        });
    }
    
private:
    template <typename TMergeRules>
    void checked_add(const std::string&  p,
                     const std::string&  test_name,
                     const jsonv::value& whole,
                     const jsonv::value& a,
                     const jsonv::value& b
                    )
    {
        if (whole.count(test_name))
        {
            jsonv::value expected = whole.at(test_name);
            _tests.emplace_back(new json_merge_test<TMergeRules>
                                    (
                                        filename(p) + "/" + test_name,
                                        a,
                                        b,
                                        expected
                                    )
                                );
        }
    }
    
private:
    std::deque<std::unique_ptr<unit_test>> _tests;
} json_merge_test_initializer_instance(test_path("merges"));

}
Exemplo n.º 28
0
int		exec_sh1(char **tab, t_shell *sh)
{
  if (tab[0][0] == '.' || tab[0][0] == '/' || slash_in_str(tab[0]) == 1)
    return (instant_exec(tab, sh->env));
  return (test_path(tab, sh->env));
}
Exemplo n.º 29
0
Arquivo: url.c Projeto: 0xheart0/vlc
int main (void)
{
    int val;

    (void)setvbuf (stdout, NULL, _IONBF, 0);
    test_decode ("this_should_not_be_modified_1234",
                 "this_should_not_be_modified_1234");

    test_decode ("This%20should%20be%20modified%201234!",
                 "This should be modified 1234!");

    test_decode ("%7E", "~");

    /* tests with invalid input */
    test_decode ("%", NULL);
    test_decode ("%2", NULL);
    test_decode ("%0000", "");

    /* Non-ASCII tests */
    test_decode ("T%C3%a9l%c3%A9vision %e2%82%Ac", "Télévision €");
    test_decode ("T%E9l%E9vision", "T\xe9l\xe9vision");

    /* Base 64 tests */
    test_b64 ("", "");
    test_b64 ("f", "Zg==");
    test_b64 ("fo", "Zm8=");
    test_b64 ("foo", "Zm9v");
    test_b64 ("foob", "Zm9vYg==");
    test_b64 ("fooba", "Zm9vYmE=");
    test_b64 ("foobar", "Zm9vYmFy");

    /* Path test */
    test_path ("/", "file:///");
    test_path ("/home/john/", "file:///home/john/");
    test_path ("/home/john//too///many//slashes",
               "file:///home/john//too///many//slashes");
    test_path ("/home/john/music.ogg", "file:///home/john/music.ogg");

    /*int fd = open (".", O_RDONLY);
    assert (fd != -1);*/
    val = chdir ("/tmp");
    assert (val != -1);

    char buf[256];
    char * tmpdir;
    tmpdir = getcwd(buf, sizeof(buf)/sizeof(*buf));
    assert (tmpdir);

    test_current_directory_path ("movie.ogg", tmpdir, "movie.ogg");
    test_current_directory_path (".", tmpdir, ".");
    test_current_directory_path ("", tmpdir, "");

    /*val = fchdir (fd);
    assert (val != -1);*/

    /* URI to path tests */
#define test( a, b ) test (vlc_uri2path, a, b)
    test ("mailto:[email protected]", NULL);
    test ("http://www.example.com/file.html#ref", NULL);
    test ("file://", NULL);
    test ("file:///", "/");
    test ("file://localhost/home/john/music%2Eogg", "/home/john/music.ogg");
    test ("file://localhost/home/john/text#ref", "/home/john/text");
    test ("file://localhost/home/john/text?name=value", "/home/john/text");
    test ("file://localhost/home/john/text?name=value#ref", "/home/john/text");
    test ("file://?name=value", NULL);
    test ("file:///?name=value", "/");
    test ("fd://0foobar", NULL);
    test ("fd://0#ref", "/dev/stdin");
    test ("fd://1", "/dev/stdout");
    test ("fd://12345", "/dev/fd/12345");
#undef test

    test_url_parse("http://example.com", "http", NULL, NULL, "example.com", 0,
                   NULL, NULL);
    test_url_parse("http://example.com/", "http", NULL, NULL, "example.com", 0,
                   "/", NULL);
    test_url_parse("http://[2001:db8::1]", "http", NULL, NULL, "2001:db8::1",
                   0, NULL, NULL);
    test_url_parse("protocol://*****:*****@1.2.3.4:567", "protocol", "john", "doe", "1.2.3.4", 567, NULL, NULL);
    test_url_parse("http://a.b/?opt=val", "http", NULL, NULL, "a.b", 0, "/", "opt=val");
    test_url_parse("p://*****:*****@host:123/a/b/c?o=v", "p", "u", "p", "host", 123, "/a/b/c", "o=v");
    test_url_parse("p://?o=v", "p", NULL, NULL, "", 0, NULL, "o=v");
    test_url_parse("p://h?o=v", "p", NULL, NULL, "h", 0, NULL, "o=v");
    test_url_parse("p://*****:*****@h:123?o=v", "p", "u", "p", "h", 123, NULL, "o=v");
    test_url_parse("p://white%20spaced", "p", NULL, NULL, "white%20spaced", 0,
                   NULL, NULL);
    test_url_parse("p://h/white%20spaced", "p", NULL, NULL, "h", 0,
                   "/white%20spaced", NULL);
    /* Invalid URIs */
    test_url_parse("p://G a r b a g e", "p", NULL, NULL, NULL, 0, NULL, NULL);
    test_url_parse("p://h/G a r b a g e", "p", NULL, NULL, "h", 0, NULL, NULL);
    return 0;
}
Exemplo n.º 30
0
int
main()
{
    cu_init();

    test_path("", NULL);
    test_path("/", "/");
    test_path(".", ".");
    test_path("./", ".");
    test_path("/.", "/");
    test_path("..", "..");
    test_path("../", "..");
    test_path("/..", NULL);
    test_path("../..", "../..");
    test_path(".//./", ".");
    test_path("..///.", "..");
    test_path("../..///", "../..");
    test_path("a", "a");
    test_path("a/", "a");
    test_path("/a", "/a");
    test_path("./a", "a");
    test_path("././a/.", "a");
    test_path("a/b", "a/b");
    test_path("/a/b/", "/a/b");
    test_path("//a//b//.", "/a/b");
    test_path("a/./b/./../.", "a");
    test_path("a/b/../..", ".");
    test_path("a/b/..//../../..", "../..");
    test_path("a/.././b", "b");
    test_path("a/../../b/..", "..");
    test_path("bla/blaa/", "bla/blaa");
    test_path("bla/blaa//", "bla/blaa");
    test_path("/bla", "/bla");
    test_path("//bla", "/bla");
    test_path("test/./bla", "test/bla");
    test_path("test/../bla", "bla");
    test_path("test/../../bla", "../bla");
    test_path("test/../../bla/be/../../..", "../..");
    test_split_join();

    test_join(".", "..", "..");
    test_join("a/b", "..", "a");
    test_join("a/b", "../..", ".");
    test_join("a/b", "../../..", "..");
    test_join("../a", "..", "..");
    test_join("../a", "../..", "../..");
    test_join(".", ".", ".");

    test_split("/", 0, ".", "/");
    test_split("/", 1, "/", ".");
    test_split(".", 0, ".", ".");
    test_split("a", 0, ".", "a");
    test_split("a", 1, "a", ".");
    test_split("a", -1, ".", "a");
    test_split("/a", 0, ".", "/a");
    test_split("/a", 1, "/", "a");
    test_split("/a", 2, "/a", ".");
    test_split("/a", -1, "/", "a");
    test_split("/a", -2, ".", "/a");
    test_split("../vu", 0, ".", "../vu");
    test_split("../vu", 1, "..", "vu");
    test_split("../vu", 2, "../vu", ".");
    test_split("../vu", -1, "..", "vu");
    test_split("../vu", -2, ".", "../vu");

    test_depth(".", 0, 0);
    test_depth("/", 1, 1);
    test_depth("a", 1, 1);
    test_depth("a/b", 2, 2);
    test_depth("..", -1, 1);
    test_depth("../..", -2, 2);
    test_depth("../a/b", 1, 3);
    test_depth("/al", 2, 2);

    return errors != 0;
}