-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from garlick/libtap
testsuite: convert unit tests to TAP
- Loading branch information
Showing
78 changed files
with
4,061 additions
and
3,677 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
|
||
die () { | ||
echo "$@" >&2 | ||
exit 1 | ||
} | ||
|
||
sudo -n /bin/true || die "passwordless sudo is required to run privileged tests" | ||
|
||
sudo -n make -C src/libnpfs check TESTS="\ | ||
test_capability.t \ | ||
test_setfsuid.t \ | ||
test_setgroups.t \ | ||
test_setreuid.t" || die "test failed" | ||
|
||
sudo -n make -C src/daemon check TESTS="\ | ||
test_multiuser.t" || die "test failed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/sh | ||
|
||
die () { | ||
echo "$@" >&2 | ||
exit 1 | ||
} | ||
|
||
which valgrind >/dev/null 2>&1 || die "valgrind is missing" | ||
|
||
TESTS="src/libnpfs/test_encoding.t \ | ||
src/libnpfs/test_fidpool.t \ | ||
src/libnpclient/test_simple.t \ | ||
src/libdiod/test_configfile.t \ | ||
src/daemon/test_read.t \ | ||
src/daemon/test_directory.t" | ||
|
||
exit_rc=0 | ||
|
||
for test in $TESTS; do | ||
valgrind \ | ||
--tool=memcheck \ | ||
--leak-check=full \ | ||
--error-exitcode=1 \ | ||
--leak-resolution=med \ | ||
--trace-children=no \ | ||
--child-silent-after-fork=yes \ | ||
$test | ||
test $? -eq 0 || exit_rc=1 | ||
done | ||
|
||
exit $exit_rc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
SUBDIRS = \ | ||
libtap \ | ||
liblsd \ | ||
libnpfs \ | ||
libnpclient \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/************************************************************\ | ||
* Copyright 2010 Lawrence Livermore National Security, LLC | ||
* (c.f. AUTHORS, NOTICE.LLNS, COPYING) | ||
* | ||
* This file is part of the diod 9P server project. | ||
* For details, see https://github.com/chaos/diod. | ||
* | ||
* SPDX-License-Identifier: GPL-2.0-or-later | ||
\************************************************************/ | ||
|
||
/* topt.c - test didomount/opt.c */ | ||
|
||
#if HAVE_CONFIG_H | ||
#include "config.h" | ||
#endif | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <errno.h> | ||
#include <stdarg.h> | ||
#include <assert.h> | ||
|
||
#include "src/libtap/tap.h" | ||
#include "opt.h" | ||
|
||
int | ||
main (int argc, char *argv[]) | ||
{ | ||
Opt o; | ||
|
||
char *s; | ||
int i; | ||
|
||
plan (NO_PLAN); | ||
|
||
o = opt_create (); | ||
ok (o != NULL, "opt_create works"); | ||
|
||
ok (opt_addf (o, "mickey=%d", 42) == 1, "opt_addf mickey=42 works"); | ||
ok (opt_addf (o, "goofey=%s", "yes") == 1, "opt_addf goofey=yes works"); | ||
ok (opt_addf (o, "donald") == 1, "opt_addf donald works"); | ||
ok (opt_addf (o, "foo,bar,baz") == 1, "opt_addf foo,bar,baz works"); | ||
ok (opt_addf (o, "lastone") == 1, "opt_addf lastone works"); | ||
|
||
s = opt_csv (o); | ||
ok (s != NULL | ||
&& !strcmp (s, "mickey=42,goofey=yes,donald,foo,bar,baz,lastone"), | ||
"opt_csv returned expected result"); | ||
free (s); | ||
|
||
ok (opt_find (o, "mickey") != NULL, "opt_find mickey works"); | ||
ok (opt_find (o, "bar") != NULL, "opt_find bar works"); | ||
ok (opt_find (o, "barn") == NULL, "opt_find barn fails as expected"); | ||
|
||
i = -1; | ||
ok (opt_scanf (o, "mickey=%d", &i) && i == 42, | ||
"opt_scanf mickey value of 42"); | ||
|
||
ok (opt_addf (o, "mickey=string,foo=%d,bar=%d,baz", 12, 15) == 1, | ||
"opt_addf mickey=string,foo=12,bar=15,baz works"); | ||
s = opt_csv (o); | ||
ok (s != NULL | ||
&& !strcmp (s, | ||
"goofey=yes,donald,lastone," | ||
"mickey=string,foo=12,bar=15,baz"), | ||
"opt_csv returned expected result"); | ||
free (s); | ||
|
||
opt_destroy (o); | ||
|
||
done_testing (); | ||
|
||
exit (0); | ||
} | ||
|
||
/* | ||
* vi:tabstop=4 shiftwidth=4 expandtab | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.