Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src tests/lint: add tests for platform characteristics



details:   https://anonhg.NetBSD.org/src/rev/400e1e86872e
branches:  trunk
changeset: 1023778:400e1e86872e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Sep 26 03:17:59 2021 +0000

description:
tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
    'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.

diffstat:

 distrib/sets/lists/tests/mi                    |  20 +++++++++++++++++-
 tests/usr.bin/xlint/lint1/Makefile             |  20 +++++++++++++++++-
 tests/usr.bin/xlint/lint1/platform_ilp32.c     |  13 +++++++++++
 tests/usr.bin/xlint/lint1/platform_ilp32.exp   |   1 +
 tests/usr.bin/xlint/lint1/platform_int.c       |  19 +++++++++++++++++
 tests/usr.bin/xlint/lint1/platform_int.exp     |   1 +
 tests/usr.bin/xlint/lint1/platform_ldbl128.c   |  12 ++++++++++
 tests/usr.bin/xlint/lint1/platform_ldbl128.exp |   1 +
 tests/usr.bin/xlint/lint1/platform_ldbl64.c    |  12 ++++++++++
 tests/usr.bin/xlint/lint1/platform_ldbl64.exp  |   1 +
 tests/usr.bin/xlint/lint1/platform_ldbl96.c    |  12 ++++++++++
 tests/usr.bin/xlint/lint1/platform_ldbl96.exp  |   1 +
 tests/usr.bin/xlint/lint1/platform_long.c      |  29 ++++++++++++++++++++++++++
 tests/usr.bin/xlint/lint1/platform_long.exp    |   1 +
 tests/usr.bin/xlint/lint1/platform_lp64.c      |  21 ++++++++++++++++++
 tests/usr.bin/xlint/lint1/platform_lp64.exp    |   1 +
 tests/usr.bin/xlint/lint1/platform_schar.c     |  13 +++++++++++
 tests/usr.bin/xlint/lint1/platform_schar.exp   |   1 +
 tests/usr.bin/xlint/lint1/platform_uchar.c     |  13 +++++++++++
 tests/usr.bin/xlint/lint1/platform_uchar.exp   |   1 +
 tests/usr.bin/xlint/lint1/t_integration.sh     |  12 ++++++----
 21 files changed, 198 insertions(+), 7 deletions(-)

diffs (truncated from 320 to 300 lines):

diff -r 23ee4531f851 -r 400e1e86872e distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sun Sep 26 03:12:50 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Sun Sep 26 03:17:59 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1129 2021/09/25 13:06:05 rillig Exp $
+# $NetBSD: mi,v 1.1130 2021/09/26 03:17:59 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -7056,6 +7056,24 @@
 ./usr/tests/usr.bin/xlint/lint1/parse_stmt_iter_error.exp      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/parse_type_name.c              tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/parse_type_name.exp            tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_ilp32.c               tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_ilp32.exp             tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_int.c                 tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_int.exp               tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_ldbl128.c             tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_ldbl128.exp           tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_ldbl64.c              tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_ldbl64.exp            tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_ldbl96.c              tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_ldbl96.exp            tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_long.c                        tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_long.exp              tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_lp64.c                        tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_lp64.exp              tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_schar.c               tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_schar.exp             tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_uchar.c               tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/platform_uchar.exp             tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/stmt_for.c                     tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/stmt_for.exp                   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/stmt_goto.c                    tests-usr.bin-tests     compattestfile,atf
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Sun Sep 26 03:12:50 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Sun Sep 26 03:17:59 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.112 2021/09/13 22:09:06 rillig Exp $
+# $NetBSD: Makefile,v 1.113 2021/09/26 03:17:59 rillig Exp $
 
 NOMAN=         # defined
 MAX_MESSAGE=   347             # see lint1/err.c
@@ -236,6 +236,24 @@
 FILES+=                parse_stmt_iter_error.exp
 FILES+=                parse_type_name.c
 FILES+=                parse_type_name.exp
+FILES+=                platform_ilp32.c
+FILES+=                platform_ilp32.exp
+FILES+=                platform_int.c
+FILES+=                platform_int.exp
+FILES+=                platform_ldbl128.c
+FILES+=                platform_ldbl128.exp
+FILES+=                platform_ldbl64.c
+FILES+=                platform_ldbl64.exp
+FILES+=                platform_ldbl96.c
+FILES+=                platform_ldbl96.exp
+FILES+=                platform_long.c
+FILES+=                platform_long.exp
+FILES+=                platform_lp64.c
+FILES+=                platform_lp64.exp
+FILES+=                platform_schar.c
+FILES+=                platform_schar.exp
+FILES+=                platform_uchar.c
+FILES+=                platform_uchar.exp
 FILES+=                stmt_for.c
 FILES+=                stmt_for.exp
 FILES+=                stmt_goto.c
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_ilp32.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_ilp32.c        Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,13 @@
+/*     $NetBSD: platform_ilp32.c,v 1.1 2021/09/26 03:17:59 rillig Exp $        */
+# 3 "platform_ilp32.c"
+
+/*
+ * Test features that only apply to platforms that have 32-bit int, long and
+ * pointer types.
+ */
+
+/* lint1-only-if: ilp32 */
+
+// TODO: Add some code that passes.
+// TODO: Add some code that fails.
+/* expect+1: warning: empty translation unit [272] */
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_ilp32.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_ilp32.exp      Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,1 @@
+platform_ilp32.c(14): warning: empty translation unit [272]
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_int.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_int.c  Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,19 @@
+/*     $NetBSD: platform_int.c,v 1.1 2021/09/26 03:17:59 rillig Exp $  */
+# 3 "platform_int.c"
+
+/*
+ * Test features that only apply to platforms on which size_t is unsigned
+ * int and ptr_diff is signed int.
+ */
+
+/* lint1-extra-flags: -h */
+/* lint1-only-if: int */
+
+void to_size(typeof(sizeof(int)));
+
+void
+convert_unsigned_char_to_size(unsigned char uc)
+{
+       /* expect+1: warning: argument #1 is converted from 'unsigned char' to 'unsigned int' due to prototype [259] */
+       to_size(uc);
+}
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_int.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_int.exp        Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,1 @@
+platform_int.c(18): warning: argument #1 is converted from 'unsigned char' to 'unsigned int' due to prototype [259]
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_ldbl128.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_ldbl128.c      Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,12 @@
+/*     $NetBSD: platform_ldbl128.c,v 1.1 2021/09/26 03:17:59 rillig Exp $      */
+# 3 "platform_ldbl128.c"
+
+/*
+ * Test features that only apply to platforms that have 128-bit long double.
+ */
+
+/* lint1-only-if: ldbl-128 */
+
+// TODO: Add some code that passes.
+// TODO: Add some code that fails.
+/* expect+1: warning: empty translation unit [272] */
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_ldbl128.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_ldbl128.exp    Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,1 @@
+platform_ldbl128.c(13): warning: empty translation unit [272]
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_ldbl64.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_ldbl64.c       Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,12 @@
+/*     $NetBSD: platform_ldbl64.c,v 1.1 2021/09/26 03:17:59 rillig Exp $       */
+# 3 "platform_ldbl64.c"
+
+/*
+ * Test features that only apply to platforms that have 64-bit long double.
+ */
+
+/* lint1-only-if: ldbl-64 */
+
+// TODO: Add some code that passes.
+// TODO: Add some code that fails.
+/* expect+1: warning: empty translation unit [272] */
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_ldbl64.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_ldbl64.exp     Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,1 @@
+platform_ldbl64.c(13): warning: empty translation unit [272]
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_ldbl96.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_ldbl96.c       Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,12 @@
+/*     $NetBSD: platform_ldbl96.c,v 1.1 2021/09/26 03:17:59 rillig Exp $       */
+# 3 "platform_ldbl96.c"
+
+/*
+ * Test features that only apply to platforms that have 96-bit long double.
+ */
+
+/* lint1-only-if: ldbl-96 */
+
+// TODO: Add some code that passes.
+// TODO: Add some code that fails.
+/* expect+1: warning: empty translation unit [272] */
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_ldbl96.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_ldbl96.exp     Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,1 @@
+platform_ldbl96.c(13): warning: empty translation unit [272]
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_long.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_long.c Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,29 @@
+/*     $NetBSD: platform_long.c,v 1.1 2021/09/26 03:17:59 rillig Exp $ */
+# 3 "platform_long.c"
+
+/*
+ * Test features that only apply to platforms on which size_t is unsigned
+ * long and ptr_diff is signed long.
+ */
+
+/* lint1-extra-flags: -h */
+/* lint1-only-if: long */
+
+void to_size(typeof(sizeof(int)));
+
+void
+convert_unsigned_char_to_size(unsigned char uc)
+{
+       /* no warning, unlike in platform_int */
+       to_size(uc);
+}
+
+/* expect+1: warning: static variable unused_variable unused [226] */
+static int unused_variable;
+
+/*
+ * XXX: On 2021-09-23, the releng build failed on i386 but not on sparc.
+ * usr.bin/make/cond.c, call to is_token with unsigned char as third argument.
+ * Based on that, this test should succeed on sparc, but with a cross-compiled
+ * lint on x86_64 with ARCHSUBDIR=sparc, it failed.
+ */
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_long.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_long.exp       Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,1 @@
+platform_long.c(22): warning: static variable unused_variable unused [226]
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_lp64.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_lp64.c Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,21 @@
+/*     $NetBSD: platform_lp64.c,v 1.1 2021/09/26 03:17:59 rillig Exp $ */
+# 3 "platform_lp64.c"
+
+/*
+ * Test features that only apply to platforms that have 32-bit int and 64-bit
+ * long and pointer types.
+ */
+
+/* lint1-only-if: lp64 */
+
+void to_size_t(typeof(sizeof(int)));
+
+void
+convert_unsigned_char_to_size_t(unsigned char uc)
+{
+       /* no warning, unlike platform_int */
+       to_size_t(uc);
+}
+
+/* expect+1: warning: static variable unused_variable unused [226] */
+static int unused_variable;
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_lp64.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_lp64.exp       Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,1 @@
+platform_lp64.c(21): warning: static variable unused_variable unused [226]
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_schar.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_schar.c        Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,13 @@
+/*     $NetBSD: platform_schar.c,v 1.1 2021/09/26 03:17:59 rillig Exp $        */
+# 3 "platform_schar.c"
+
+/*
+ * Test features that only apply to platforms where plain char has the same
+ * representation as signed char.
+ */
+
+/* lint1-only-if: schar */
+
+// TODO: Add some code that passes.
+// TODO: Add some code that fails.
+/* expect+1: warning: empty translation unit [272] */
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_schar.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_schar.exp      Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,1 @@
+platform_schar.c(14): warning: empty translation unit [272]
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_uchar.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_uchar.c        Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,13 @@
+/*     $NetBSD: platform_uchar.c,v 1.1 2021/09/26 03:17:59 rillig Exp $        */
+# 3 "platform_uchar.c"
+
+/*
+ * Test features that only apply to platforms where plain char has the same
+ * representation as unsigned char.
+ */
+
+/* lint1-only-if: uchar */
+
+// TODO: Add some code that passes.
+// TODO: Add some code that fails.
+/* expect+1: warning: empty translation unit [272] */
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/platform_uchar.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_uchar.exp      Sun Sep 26 03:17:59 2021 +0000
@@ -0,0 +1,1 @@
+platform_uchar.c(14): warning: empty translation unit [272]
diff -r 23ee4531f851 -r 400e1e86872e tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh        Sun Sep 26 03:12:50 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh        Sun Sep 26 03:17:59 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.70 2021/09/10 20:02:51 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.71 2021/09/26 03:17:59 rillig Exp $
 #



Home | Main Index | Thread Index | Old Index