summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/alloc.c6
-rw-r--r--tests/bfstd.c6
-rw-r--r--tests/bit.c6
-rw-r--r--tests/common/empty.out (renamed from tests/gnu/empty.out)0
-rw-r--r--tests/common/empty.sh (renamed from tests/gnu/empty.sh)0
-rw-r--r--tests/common/empty_error.out3
-rw-r--r--tests/common/empty_error.sh7
-rw-r--r--tests/common/empty_special.out (renamed from tests/gnu/empty_special.out)0
-rw-r--r--tests/common/empty_special.sh (renamed from tests/gnu/empty_special.sh)0
-rw-r--r--tests/ioq.c10
-rw-r--r--tests/main.c6
-rw-r--r--tests/mksock.c2
-rw-r--r--tests/tests.h4
-rw-r--r--tests/trie.c6
-rw-r--r--tests/util.sh9
-rw-r--r--tests/xspawn.c25
-rw-r--r--tests/xtime.c8
-rw-r--r--tests/xtouch.c12
18 files changed, 54 insertions, 56 deletions
diff --git a/tests/alloc.c b/tests/alloc.c
index 9f08111..6c0defd 100644
--- a/tests/alloc.c
+++ b/tests/alloc.c
@@ -1,10 +1,10 @@
// Copyright © Tavian Barnes <tavianator@tavianator.com>
// SPDX-License-Identifier: 0BSD
+#include "prelude.h"
#include "tests.h"
-#include "../src/alloc.h"
-#include "../src/config.h"
-#include "../src/diag.h"
+#include "alloc.h"
+#include "diag.h"
#include <errno.h>
#include <stdlib.h>
#include <stdint.h>
diff --git a/tests/bfstd.c b/tests/bfstd.c
index dc5ceaa..07b68b0 100644
--- a/tests/bfstd.c
+++ b/tests/bfstd.c
@@ -1,10 +1,10 @@
// Copyright © Tavian Barnes <tavianator@tavianator.com>
// SPDX-License-Identifier: 0BSD
+#include "prelude.h"
#include "tests.h"
-#include "../src/bfstd.h"
-#include "../src/config.h"
-#include "../src/diag.h"
+#include "bfstd.h"
+#include "diag.h"
#include <errno.h>
#include <langinfo.h>
#include <stdlib.h>
diff --git a/tests/bit.c b/tests/bit.c
index 6548c30..674d1b2 100644
--- a/tests/bit.c
+++ b/tests/bit.c
@@ -1,10 +1,10 @@
// Copyright © Tavian Barnes <tavianator@tavianator.com>
// SPDX-License-Identifier: 0BSD
+#include "prelude.h"
#include "tests.h"
-#include "../src/bit.h"
-#include "../src/config.h"
-#include "../src/diag.h"
+#include "bit.h"
+#include "diag.h"
#include <limits.h>
#include <stdint.h>
#include <string.h>
diff --git a/tests/gnu/empty.out b/tests/common/empty.out
index a0f4b76..a0f4b76 100644
--- a/tests/gnu/empty.out
+++ b/tests/common/empty.out
diff --git a/tests/gnu/empty.sh b/tests/common/empty.sh
index 95ee988..95ee988 100644
--- a/tests/gnu/empty.sh
+++ b/tests/common/empty.sh
diff --git a/tests/common/empty_error.out b/tests/common/empty_error.out
new file mode 100644
index 0000000..da45e23
--- /dev/null
+++ b/tests/common/empty_error.out
@@ -0,0 +1,3 @@
+./bar
+./baz
+./qux
diff --git a/tests/common/empty_error.sh b/tests/common/empty_error.sh
new file mode 100644
index 0000000..7c8049c
--- /dev/null
+++ b/tests/common/empty_error.sh
@@ -0,0 +1,7 @@
+cd "$TEST"
+
+"$XTOUCH" -p foo/ bar/ baz qux
+chmod -r foo baz
+defer chmod +r foo baz
+
+! bfs_diff . -empty
diff --git a/tests/gnu/empty_special.out b/tests/common/empty_special.out
index fa35478..fa35478 100644
--- a/tests/gnu/empty_special.out
+++ b/tests/common/empty_special.out
diff --git a/tests/gnu/empty_special.sh b/tests/common/empty_special.sh
index 31e9d2e..31e9d2e 100644
--- a/tests/gnu/empty_special.sh
+++ b/tests/common/empty_special.sh
diff --git a/tests/ioq.c b/tests/ioq.c
index 1ce8f75..ef5ee3b 100644
--- a/tests/ioq.c
+++ b/tests/ioq.c
@@ -1,12 +1,12 @@
// Copyright © Tavian Barnes <tavianator@tavianator.com>
// SPDX-License-Identifier: 0BSD
+#include "prelude.h"
#include "tests.h"
-#include "../src/ioq.h"
-#include "../src/bfstd.h"
-#include "../src/config.h"
-#include "../src/diag.h"
-#include "../src/dir.h"
+#include "ioq.h"
+#include "bfstd.h"
+#include "diag.h"
+#include "dir.h"
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
diff --git a/tests/main.c b/tests/main.c
index 69903d4..429772b 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -5,10 +5,10 @@
* Entry point for unit tests.
*/
+#include "prelude.h"
#include "tests.h"
-#include "../src/bfstd.h"
-#include "../src/color.h"
-#include "../src/config.h"
+#include "bfstd.h"
+#include "color.h"
#include <errno.h>
#include <locale.h>
#include <stdio.h>
diff --git a/tests/mksock.c b/tests/mksock.c
index f3b61da..5786cb6 100644
--- a/tests/mksock.c
+++ b/tests/mksock.c
@@ -6,7 +6,7 @@
* program does the job.
*/
-#include "../src/bfstd.h"
+#include "bfstd.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tests/tests.h b/tests/tests.h
index 351badb..9078938 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -8,8 +8,8 @@
#ifndef BFS_TESTS_H
#define BFS_TESTS_H
-#include "../src/config.h"
-#include "../src/diag.h"
+#include "prelude.h"
+#include "diag.h"
/** Unit test function type. */
typedef bool test_fn(void);
diff --git a/tests/trie.c b/tests/trie.c
index fec0de2..4667322 100644
--- a/tests/trie.c
+++ b/tests/trie.c
@@ -1,10 +1,10 @@
// Copyright © Tavian Barnes <tavianator@tavianator.com>
// SPDX-License-Identifier: 0BSD
+#include "prelude.h"
#include "tests.h"
-#include "../src/trie.h"
-#include "../src/config.h"
-#include "../src/diag.h"
+#include "trie.h"
+#include "diag.h"
#include <stdlib.h>
#include <string.h>
diff --git a/tests/util.sh b/tests/util.sh
index 7dba9fb..3969db5 100644
--- a/tests/util.sh
+++ b/tests/util.sh
@@ -12,12 +12,9 @@ _realpath() (
)
# Globals
-TESTS=$(_realpath "$TESTS")
-if [ "${BUILDDIR-}" ]; then
- BIN=$(_realpath "$BUILDDIR/bin")
-else
- BIN=$(_realpath "$TESTS/../bin")
-fi
+ROOT=$(_realpath "$(dirname -- "$TESTS")")
+TESTS="$ROOT/tests"
+BIN="$ROOT/bin"
MKSOCK="$BIN/tests/mksock"
XTOUCH="$BIN/tests/xtouch"
UNAME=$(uname)
diff --git a/tests/xspawn.c b/tests/xspawn.c
index c1bac36..785ea48 100644
--- a/tests/xspawn.c
+++ b/tests/xspawn.c
@@ -1,12 +1,12 @@
// Copyright © Tavian Barnes <tavianator@tavianator.com>
// SPDX-License-Identifier: 0BSD
+#include "prelude.h"
#include "tests.h"
-#include "../src/alloc.h"
-#include "../src/bfstd.h"
-#include "../src/config.h"
-#include "../src/dstring.h"
-#include "../src/xspawn.h"
+#include "alloc.h"
+#include "bfstd.h"
+#include "dstring.h"
+#include "xspawn.h"
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
@@ -64,27 +64,20 @@ static bool check_use_path(bool use_posix) {
spawn.flags &= ~BFS_SPAWN_USE_POSIX;
}
- const char *builddir = getenv("BUILDDIR");
- dchar *bin = dstrprintf("%s/bin", builddir ? builddir : ".");
- ret &= bfs_pcheck(bin, "dstrprintf()");
- if (!ret) {
- goto destroy;
- }
-
- ret &= bfs_pcheck(bfs_spawn_addopen(&spawn, 10, bin, O_RDONLY | O_DIRECTORY, 0) == 0);
+ ret &= bfs_pcheck(bfs_spawn_addopen(&spawn, 10, "bin", O_RDONLY | O_DIRECTORY, 0) == 0);
ret &= bfs_pcheck(bfs_spawn_adddup2(&spawn, 10, 11) == 0);
ret &= bfs_pcheck(bfs_spawn_addclose(&spawn, 10) == 0);
ret &= bfs_pcheck(bfs_spawn_addfchdir(&spawn, 11) == 0);
ret &= bfs_pcheck(bfs_spawn_addclose(&spawn, 11) == 0);
if (!ret) {
- goto bin;
+ goto destroy;
}
// Check that $PATH is resolved in the parent's environment
char **envp;
ret &= bfs_pcheck(envp = envdup());
if (!ret) {
- goto bin;
+ goto destroy;
}
// Check that $PATH is resolved after the file actions
@@ -138,8 +131,6 @@ env:
free(*var);
}
free(envp);
-bin:
- dstrfree(bin);
destroy:
ret &= bfs_pcheck(bfs_spawn_destroy(&spawn) == 0);
out:
diff --git a/tests/xtime.c b/tests/xtime.c
index f85402e..a7c63d2 100644
--- a/tests/xtime.c
+++ b/tests/xtime.c
@@ -1,11 +1,11 @@
// Copyright © Tavian Barnes <tavianator@tavianator.com>
// SPDX-License-Identifier: 0BSD
+#include "prelude.h"
#include "tests.h"
-#include "../src/xtime.h"
-#include "../src/bfstd.h"
-#include "../src/config.h"
-#include "../src/diag.h"
+#include "xtime.h"
+#include "bfstd.h"
+#include "diag.h"
#include <errno.h>
#include <limits.h>
#include <stdint.h>
diff --git a/tests/xtouch.c b/tests/xtouch.c
index fad272f..cd41842 100644
--- a/tests/xtouch.c
+++ b/tests/xtouch.c
@@ -1,10 +1,10 @@
// Copyright © Tavian Barnes <tavianator@tavianator.com>
// SPDX-License-Identifier: 0BSD
-#include "../src/bfstd.h"
-#include "../src/config.h"
-#include "../src/sanity.h"
-#include "../src/xtime.h"
+#include "prelude.h"
+#include "bfstd.h"
+#include "sanity.h"
+#include "xtime.h"
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@@ -237,8 +237,8 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "%s: '%s': %s\n", cmd, rarg, xstrerror(errno));
return EXIT_FAILURE;
}
- times[0] = buf.st_atim;
- times[1] = buf.st_mtim;
+ times[0] = ST_ATIM(buf);
+ times[1] = ST_MTIM(buf);
} else if (darg) {
if (xgetdate(darg, &times[0]) != 0) {
fprintf(stderr, "%s: Parsing time '%s' failed: %s\n", cmd, darg, xstrerror(errno));