there was an #include directive missing
[openmpi-llc.git] / test / util / opal_basename.c
blobb1eede27001298df46458bbe761a2db7a90c51cf
1 /*
2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2005 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * $COPYRIGHT$
14 * Additional copyrights may follow
16 * $HEADER$
19 #include "ompi_config.h"
21 #include <stdio.h>
22 #include <string.h>
23 #include <stdlib.h>
25 #include "support.h"
26 #include "opal/constants.h"
27 #include "opal/util/basename.h"
30 static void test(const char* in, const char* out);
33 int main(int argc, char* argv[])
35 test_init("opal_basename()");
37 test("foo.txt", "foo.txt");
38 test("/foo/bar/baz", "baz");
39 test("/yow.c", "yow.c");
40 test("/", "/");
42 test("foo.txt/", "foo.txt");
43 test("/foo/bar/baz/", "baz");
44 test("/yow.c/", "yow.c");
45 test("//", "/");
47 #ifdef __WINDOWS__
48 test("C:\\foo\\bar\\baz", "baz");
49 test("D:foo.txt", "foo.txt");
50 test("E:\\yow.c", "yow.c");
51 test("F:", "F:");
52 test("G:\\", "G:\\");
53 #endif
55 /* All done */
56 return test_finalize();
60 void test(const char* in, const char* out)
62 char *msg;
63 char *ret = opal_basename(in);
65 if (0 == strcmp(ret, out)) {
66 test_success();
67 } else {
68 asprintf(&msg, "Mismatch: input \"%s\", expected \"%s\", got \"%s\"\n",
69 in, out, ret);
70 test_failure(msg);
71 free(msg);
73 if (NULL != ret) {
74 free(ret);