: ".");
}
+#ifndef _WIN32
/* Returns the directory name portion of 'file_name' as a malloc()'d string,
* similar to the POSIX dirname() function but thread-safe. */
char *
return xmemdup0(file_name + start, end - start);
}
+#endif /* _WIN32 */
/* If 'file_name' starts with '/', returns a copy of 'file_name'. Otherwise,
* returns an absolute path to 'file_name' considering it relative to 'dir',
const char *english_list_delimiter(size_t index, size_t total);
char *get_cwd(void);
+#ifndef _WIN32
char *dir_name(const char *file_name);
char *base_name(const char *file_name);
+#endif
char *abs_file_name(const char *dir, const char *file_name);
char *follow_symlinks(const char *filename);
/test-controller.8
/test-controller
/test-csum
-/test-file_name
/test-flows
/test-hash
/test-heap
tests/valgrind/test-classifier \
tests/valgrind/test-cmap \
tests/valgrind/test-csum \
- tests/valgrind/test-file_name \
tests/valgrind/test-flows \
tests/valgrind/test-hash \
tests/valgrind/test-hindex \
tests/test-classifier.c \
tests/test-cmap.c \
tests/test-csum.c \
- tests/test-file_name.c \
tests/test-flows.c \
tests/test-hash.c \
tests/test-heap.c \
m4_define([CHECK_FILE_NAME],
[AT_SETUP([components of "$1" are "$2", "$3"])
+ AT_SKIP_IF([test "$IS_WIN32" = "yes"])
AT_KEYWORDS([dir_name base_name])
- AT_CHECK([ovstest test-file_name "AS_ESCAPE($1)"], [0], [$2
+ AT_CHECK([ovstest test-util file_name "AS_ESCAPE($1)"], [0], [$2
$3
])
AT_CLEANUP])
+++ /dev/null
-/*
- * Copyright (c) 2009, 2010, 2014 Nicira, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <config.h>
-#include "util.h"
-#include <stdlib.h>
-#include "ovstest.h"
-
-static void
-test_filename_main(int argc, char *argv[])
-{
- int i;
-
- for (i = 1; i < argc; i++) {
- char *dir, *base;
-
- dir = dir_name(argv[i]);
- puts(dir);
- free(dir);
-
- base = base_name(argv[i]);
- puts(base);
- free(base);
- }
-}
-
-OVSTEST_REGISTER("test-file_name", test_filename_main);
ovs_assert(snprintf(NULL, 0, "abcde") == 5);
}
+
+#ifndef _WIN32
+static void
+test_file_name(int argc, char *argv[])
+{
+ int i;
+
+ for (i = 1; i < argc; i++) {
+ char *dir, *base;
+
+ dir = dir_name(argv[i]);
+ puts(dir);
+ free(dir);
+
+ base = base_name(argv[i]);
+ puts(base);
+ free(base);
+ }
+}
+#endif /* _WIN32 */
\f
static const struct command commands[] = {
{"ctz", 0, 0, test_ctz},
{"assert", 0, 0, test_assert},
{"ovs_scan", 0, 0, test_ovs_scan},
{"snprintf", 0, 0, test_snprintf},
+#ifndef _WIN32
+ {"file_name", 1, INT_MAX, test_file_name},
+#endif
{NULL, 0, 0, NULL},
};