freebsd-src/usr.bin/unifdef/tests/unifdef_test.sh
Warner Losh 5e3934b15a usr.bin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:01 -07:00

43 lines
871 B
Bash

#
# Copyright (c) 2023 Klara, Inc.
#
# SPDX-License-Identifier: BSD-2-Clause
#
atf_test_case hash_comment
hash_comment_head() {
atf_set descr "multiline comment follows directive"
}
hash_comment_body() {
cat >f <<EOF
*/
EOF
atf_check -o file:f unifdef <f
}
atf_test_case redefine
redefine_head() {
atf_set descr "redefine the same symbol"
}
redefine_body() {
cat >file <<EOF
#if FOO
a
#else
b
#endif
EOF
atf_check -s exit:1 -o inline:"a\n" unifdef -DFOO <file
atf_check -s exit:1 -o inline:"a\n" unifdef -UFOO -DFOO <file
atf_check -s exit:1 -o inline:"a\n" unifdef -DFOO=0 -DFOO <file
atf_check -s exit:1 -o inline:"b\n" unifdef -UFOO <file
atf_check -s exit:1 -o inline:"b\n" unifdef -DFOO -UFOO <file
atf_check -s exit:1 -o inline:"b\n" unifdef -DFOO -DFOO=0 <file
}
atf_init_test_cases() {
atf_add_test_case hash_comment
atf_add_test_case redefine
}