mirror of
https://git.sr.ht/~cismonx/bookmarkfs
synced 2025-07-19 07:38:51 +00:00
Since we're only using the feature variables in shell expansion, using this form should make the testsuite code look cleaner.
100 lines
2.4 KiB
Text
100 lines
2.4 KiB
Text
dnl
|
|
dnl Copyright (C) 2025 CismonX <admin@cismon.net>
|
|
dnl
|
|
dnl Copying and distribution of this file, with or without modification,
|
|
dnl are permitted in any medium without royalty,
|
|
dnl provided the copyright notice and this notice are preserved.
|
|
dnl This file is offered as-is, without any warranty.
|
|
dnl
|
|
|
|
AT_INIT
|
|
|
|
m4_define([ATX_FAIL], [exit 99])
|
|
m4_define([ATX_SKIP], [exit 77])
|
|
|
|
dnl
|
|
dnl ATX_FEAT_VAR(feature)
|
|
dnl
|
|
dnl Expands to the shell variable indicating whether the given feature
|
|
dnl is defined by BOOKMARKFS_FEAT() and enabled during `configure`.
|
|
dnl
|
|
dnl A non-empty value indicates that the feature is enabled.
|
|
dnl
|
|
m4_define([ATX_FEAT_VAR], [[${feat_]m4_translit($1, [-], [_])[}]])
|
|
|
|
dnl
|
|
dnl ATX_FEAT_IF(feature, [action-if-enabled], [action-if-disabled])
|
|
dnl
|
|
dnl Conditionally run script depending on whether a feature is enabled.
|
|
dnl
|
|
m4_define([ATX_FEAT_IF], [
|
|
if test -n "ATX_FEAT_VAR($1)"; then :
|
|
$2
|
|
else :
|
|
$3
|
|
fi
|
|
])
|
|
|
|
dnl
|
|
dnl ATX_FEAT_PREREQ(features...)
|
|
dnl
|
|
dnl If any of the given features is not enabled, skip the current test.
|
|
dnl
|
|
m4_define([ATX_FEAT_PREREQ], [
|
|
if test -z "m4_map([ATX_FEAT_VAR], [$@])"; then
|
|
ATX_SKIP
|
|
fi
|
|
])
|
|
|
|
dnl
|
|
dnl ATX_RUN_ONE(cmd)
|
|
dnl
|
|
dnl Run a pipeline of shell command(s).
|
|
dnl If it exits with a non-zero status, fail the current test.
|
|
dnl
|
|
m4_define([ATX_RUN_ONE], [
|
|
m4_ifnblank([$1], [
|
|
if $1; then :
|
|
else
|
|
echo "exit status: $?"
|
|
ATX_FAIL
|
|
fi
|
|
])
|
|
])
|
|
|
|
dnl
|
|
dnl ATX_RUN(cmd_list)
|
|
dnl
|
|
dnl Like ATX_RUN_ONE, but takes multiple pipelines, separated by newline.
|
|
dnl If any exits with a non-zero status, fail the current test.
|
|
dnl
|
|
m4_define([ATX_RUN], [
|
|
m4_map([ATX_RUN_ONE], m4_split([$1], m4_newline([+])))
|
|
])
|
|
|
|
m4_define([ATX_CHECK_SIMPLE], [
|
|
AT_CHECK([$1], , [ignore], [ignore])
|
|
])
|
|
|
|
m4_define([ATX_CHECK_LIB], [
|
|
ATX_CHECK_SIMPLE([
|
|
ATX_FEAT_PREREQ([bookmarkfs-util])
|
|
$1
|
|
])
|
|
])
|
|
|
|
AT_TEST_HELPER_FN([rand_u64_hex], , , [
|
|
echo $(od -vAn -N8 -tx8 /dev/urandom | tr -d ' ')
|
|
])
|
|
|
|
AT_TEST_HELPER_FN([rand_base64], , , [
|
|
# The `base64` utility is not specified by POSIX,
|
|
# but present in GNU Coreutils, BusyBox and the FreeBSD base system.
|
|
echo $(head -c$1 /dev/urandom | base64 -w0)
|
|
])
|
|
|
|
AT_BANNER([The Utility Library])
|
|
m4_include([lib_hash.at])
|
|
m4_include([lib_prng.at])
|
|
m4_include([lib_watcher.at])
|
|
m4_include([lib_sandbox.at])
|