From f3812c2b5351c9f0dcae9da0d62f44516c0ae595 Mon Sep 17 00:00:00 2001 From: christos Date: Sun, 8 Mar 2020 17:21:52 +0000 Subject: [PATCH] Add an ifdef test --- tests/usr.bin/config/Makefile | 3 +- tests/usr.bin/config/d_ifdef | 52 ++++++++++++++++++++++++++++++++ tests/usr.bin/config/t_config.sh | 42 +++++++++++++++++++++++++- 3 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 tests/usr.bin/config/d_ifdef diff --git a/tests/usr.bin/config/Makefile b/tests/usr.bin/config/Makefile index 491b289f58f2..026df017f421 100644 --- a/tests/usr.bin/config/Makefile +++ b/tests/usr.bin/config/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2 2014/10/29 16:24:32 uebayasi Exp $ +# $NetBSD: Makefile,v 1.3 2020/03/08 17:21:52 christos Exp $ SUBDIR= support @@ -12,6 +12,7 @@ TESTS_SH= t_config FILESDIR= ${TESTSDIR} FILES= d_deffs_redef +FILES+= d_ifdef FILES+= d_loop FILES+= d_loop2 FILES+= d_min diff --git a/tests/usr.bin/config/d_ifdef b/tests/usr.bin/config/d_ifdef new file mode 100644 index 000000000000..11c4489848c7 --- /dev/null +++ b/tests/usr.bin/config/d_ifdef @@ -0,0 +1,52 @@ +include "arch/regress/conf/std.regress" +maxusers 4 + +define TRUE +ifdef TRUE +options OK1_1 +elifdef FALSE +options BAD1_1 +elifdef TRUE +options BAD1_2 +else +options BAD1_3 +endif + +ifdef FALSE +options BAD2_1 +elifdef TRUE +ifdef FALSE +options BAD2_2 +elifdef TRUE +options OK2_1 +else +options BAD2_3 +endif +options OK2_2 +endif + +ifdef FALSE +options BAD3_1 +elifdef TRUE +ifdef FALSE +options BAD3_2 +else +options OK3_1 +ifdef TRUE +ifdef FALSE +options BAD3_3 +elifdef TRUE +options OK3_2 +endif +options OK3_3 +elifdef TRUE +options BAD3_4 +else +options BAD3_5 +endif +options OK3_4 +endif +options OK3_5 +endif + +config regress root on ? diff --git a/tests/usr.bin/config/t_config.sh b/tests/usr.bin/config/t_config.sh index 55af069f5afd..0fdbd478cba3 100644 --- a/tests/usr.bin/config/t_config.sh +++ b/tests/usr.bin/config/t_config.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_config.sh,v 1.8 2016/08/27 12:08:14 christos Exp $ +# $NetBSD: t_config.sh,v 1.9 2020/03/08 17:21:52 christos Exp $ # # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. # All rights reserved. @@ -260,6 +260,45 @@ min_body() { test_output min } +# Check ifdef supper +test_case ifdef pass "ifdef config" +check_ifdef_files() +{ + test -e Makefile && + test -e config_file.h && + test -e config_time.src && + test -e ioconf.c && + test -e ioconf.h && + test -e locators.h && + test -e swapregress.c && + test -h machine && + test -h regress && + : +} + +check_ifdef_makefile() +{ + local f=Makefile + local e='-DOK1_1 -DOK2_1 -DOK2_2 -DOK3_1 -DOK3_2 -DOK3_3 -DOK3_4 -DOK3_5 -DMAXUSERS="4"' + local r + r=$(make -f Makefile -V IDENT) + if [ "$r" != "$e" ]; then + echo "Expected: '$e'" + echo "Result: '$r'" + return 1 + fi +} + +check_ifdef() +{ + check_ifdef_files && + check_ifdef_makefile && + : +} +ifdef_body() { + test_output ifdef +} + atf_init_test_cases() { atf_add_test_case shadow_instance @@ -275,4 +314,5 @@ atf_init_test_cases() atf_add_test_case no_select atf_add_test_case devi atf_add_test_case min + atf_add_test_case ifdef }