summaryrefslogtreecommitdiffstats
path: root/tests/bfstd.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-05-19 11:33:32 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-05-19 11:33:32 -0400
commitf642b3dd1271e4a1503ce7629ba36e25d6a59fce (patch)
tree5325248dddc0aa0119d069490da498b49dd0bb55 /tests/bfstd.c
parent526133c11eb9a26a4cffb20bcd10bcbb36d940de (diff)
downloadbfs-f642b3dd1271e4a1503ce7629ba36e25d6a59fce.tar.xz
tests/bfstd: Use bfs_verify() over explicit abort()
Diffstat (limited to 'tests/bfstd.c')
-rw-r--r--tests/bfstd.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/tests/bfstd.c b/tests/bfstd.c
index 1812a00..7fea9b5 100644
--- a/tests/bfstd.c
+++ b/tests/bfstd.c
@@ -4,6 +4,7 @@
#include "../src/bfstd.h"
#include "../src/config.h"
#include "../src/diag.h"
+#include <errno.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@@ -12,23 +13,13 @@
/** Check the result of xdirname()/xbasename(). */
static void check_base_dir(const char *path, const char *dir, const char *base) {
char *xdir = xdirname(path);
- if (!xdir) {
- perror("xdirname()");
- abort();
- } else if (strcmp(xdir, dir) != 0) {
- fprintf(stderr, "xdirname(\"%s\") == \"%s\" (!= \"%s\")\n", path, xdir, dir);
- abort();
- }
+ bfs_verify(xdir, "xdirname(): %s", strerror(errno));
+ bfs_verify(strcmp(xdir, dir) == 0, "xdirname('%s') == '%s' (!= '%s')", path, xdir, dir);
free(xdir);
char *xbase = xbasename(path);
- if (!xbase) {
- perror("xbasename()");
- abort();
- } else if (strcmp(xbase, base) != 0) {
- fprintf(stderr, "xbasename(\"%s\") == \"%s\" (!= \"%s\")\n", path, xbase, base);
- abort();
- }
+ bfs_verify(xbase, "xbasename(): %s", strerror(errno));
+ bfs_verify(strcmp(xbase, base) == 0, "xbasename('%s') == '%s' (!= '%s')", path, xbase, base);
free(xbase);
}