From: schwarze Date: Tue, 30 Aug 2016 22:20:03 +0000 (+0000) Subject: Test handling of invalid pointers in the pages table. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=998de4a5d57cc7a6e448ce21397780c533dc486d;p=openbsd Test handling of invalid pointers in the pages table. In such cases, do not access NULL pointers in dbm_dump. Make the setup in the run/Makefile a bit more systematic. Output starts getting too long, so make everything silent; you can always use "make -dl" to debug specific tests. --- diff --git a/regress/usr.bin/mandoc/db/dbm_dump/dbm_dump.c b/regress/usr.bin/mandoc/db/dbm_dump/dbm_dump.c index fa08e59909f..22761e2c298 100644 --- a/regress/usr.bin/mandoc/db/dbm_dump/dbm_dump.c +++ b/regress/usr.bin/mandoc/db/dbm_dump/dbm_dump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dbm_dump.c,v 1.1 2016/07/30 10:56:13 schwarze Exp $ */ +/* $OpenBSD: dbm_dump.c,v 1.2 2016/08/30 22:20:03 schwarze Exp $ */ /* * Copyright (c) 2016 Ingo Schwarze * @@ -109,6 +109,10 @@ dump_pages(union ptr p) dump_str(&descp); printf("\npage file "); pchk(dbm_get(*p.i++), &filep, "file", 0); + if (filep == NULL) { + printf("# (NULL)\n"); + continue; + } switch(*filep++) { case 1: printf("src "); @@ -188,6 +192,10 @@ dump_macro(union ptr p, int32_t im) static void dump_str(const char **cp) { + if (*cp == NULL) { + printf("(NULL)"); + return; + } if (**cp <= (char)NAME_MASK) { putchar('['); if (**cp & NAME_FILE) @@ -212,6 +220,10 @@ dump_str(const char **cp) static void dump_lst(const char **cp) { + if (*cp == NULL) { + printf("# (NULL)\n"); + return; + } while (**cp != '\0') { printf("# "); dump_str(cp); @@ -223,7 +235,14 @@ dump_lst(const char **cp) static void pchk(const char *want, const char **got, const char *name, int fuzz) { - if (*got > want || *got + fuzz < want) + if (want == NULL) { + warnx("%s wants (NULL), ignoring", name); + return; + } + if (*got == NULL) + warnx("%s jumps from (NULL) to 0x%x", name, + be32toh(dbm_addr(want))); + else if (*got > want || *got + fuzz < want) warnx("%s jumps from 0x%x to 0x%x", name, be32toh(dbm_addr(*got)), be32toh(dbm_addr(want))); *got = want; diff --git a/regress/usr.bin/mandoc/db/out/all.derr b/regress/usr.bin/mandoc/db/out/all.derr index fb3157687d9..fe27b49c547 100644 --- a/regress/usr.bin/mandoc/db/out/all.derr +++ b/regress/usr.bin/mandoc/db/out/all.derr @@ -45,6 +45,59 @@ dbm_dump: value0 jumps from 0xf4 to 0xfc >>> padfmagic dbm_dump: end jumps from 0x138 to 0x13c +>>> badname0 +dbm_dump: dbm_get: Database corrupt: offset -1 +dbm_dump: dbm_get: Database corrupt: offset -1 +dbm_dump: name wants (NULL), ignoring +dbm_dump: name0 wants (NULL), ignoring +dbm_dump: sect0 jumps from (NULL) to 0x30 + +>>> badname +dbm_dump: dbm_get: Database corrupt: offset -1 +dbm_dump: name wants (NULL), ignoring + +>>> badsect0 +dbm_dump: dbm_get: Database corrupt: offset -1 +dbm_dump: dbm_get: Database corrupt: offset -1 +dbm_dump: sect wants (NULL), ignoring +dbm_dump: sect0 wants (NULL), ignoring +dbm_dump: desc0 jumps from (NULL) to 0x33 + +>>> badsect +dbm_dump: dbm_get: Database corrupt: offset -1 +dbm_dump: sect wants (NULL), ignoring + +>>> badarch0 +dbm_dump: dbm_get: Database corrupt: offset -1 +dbm_dump: dbm_get: Database corrupt: offset -1 +dbm_dump: arch0 jumps from 0x71 to 0x78 + +>>> badarch +dbm_dump: dbm_get: Database corrupt: offset -1 +dbm_dump: arch wants (NULL), ignoring + +>>> baddesc0 +dbm_dump: dbm_get: Database corrupt: offset -1 +dbm_dump: dbm_get: Database corrupt: offset -1 +dbm_dump: desc wants (NULL), ignoring +dbm_dump: desc0 wants (NULL), ignoring +dbm_dump: file0 jumps from (NULL) to 0x3c + +>>> baddesc +dbm_dump: dbm_get: Database corrupt: offset -1 +dbm_dump: desc wants (NULL), ignoring + +>>> badfile0 +dbm_dump: dbm_get: Database corrupt: offset -1 +dbm_dump: dbm_get: Database corrupt: offset -1 +dbm_dump: file wants (NULL), ignoring +dbm_dump: file0 wants (NULL), ignoring +dbm_dump: macros jumps from (NULL) to 0x4c + +>>> badfile +dbm_dump: dbm_get: Database corrupt: offset -1 +dbm_dump: file wants (NULL), ignoring + >>> nonexistent dbm_dump: nonexistent.db: No such file or directory diff --git a/regress/usr.bin/mandoc/db/out/all.merr b/regress/usr.bin/mandoc/db/out/all.merr new file mode 100644 index 00000000000..bf5fe66b13c --- /dev/null +++ b/regress/usr.bin/mandoc/db/out/all.merr @@ -0,0 +1,36 @@ + +>>> empty +man: nothing appropriate + +>>> badname0 +man: dbm_get: Database corrupt: offset -1 +man: No entry for empty in the manual. + +>>> badname +man: dbm_get: Database corrupt: offset -1 + +>>> badsect0 +man: dbm_get: Database corrupt: offset -1 +man: No entry for empty in the manual. + +>>> badsect +man: dbm_get: Database corrupt: offset -1 + +>>> badarch0 +man: dbm_get: Database corrupt: offset -1 + +>>> badarch +man: dbm_get: Database corrupt: offset -1 + +>>> baddesc0 +man: dbm_get: Database corrupt: offset -1 +man: dbm_get: Database corrupt: offset -1 + +>>> baddesc +man: dbm_get: Database corrupt: offset -1 + +>>> badfile0 +man: dbm_get: Database corrupt: offset -1 + +>>> badfile +man: dbm_get: Database corrupt: offset -1 diff --git a/regress/usr.bin/mandoc/db/out/all.mout b/regress/usr.bin/mandoc/db/out/all.mout index dae720bc5e4..21404fa377e 100644 --- a/regress/usr.bin/mandoc/db/out/all.mout +++ b/regress/usr.bin/mandoc/db/out/all.mout @@ -1,6 +1,4 @@ ->>> empty - >>> onepage empty(1) - no title @@ -50,6 +48,14 @@ empty(1, 8) - no title >>> twoarch empty(1/amd64, i386) - no title +>>> threearch +> amd64 +man1/amd64/empty.1 +> i386 +man1/i386/empty.1 +> sgi +man1/sgi/empty.1 + >>> fn > fn_type man3/fn.3 @@ -60,6 +66,7 @@ man3/fn.3 > fo_type man3/fn.3 > fo_func +man: nothing appropriate > fo_arg man3/fn.3 @@ -92,3 +99,40 @@ man1/sh.1 man1/xr.1 > page man1/xr.1 + +>>> empty + +>>> badname0 + +>>> badname +/usr/obj/regress/usr.bin/mandoc/db/run/man/man1/empty.1 +/usr/obj/regress/usr.bin/mandoc/db/run/man/man1/second.1 +/usr/obj/regress/usr.bin/mandoc/db/run/man/man1/third.1 + +>>> badsect0 + +>>> badsect +/usr/obj/regress/usr.bin/mandoc/db/run/man/man1/empty.1 +/usr/obj/regress/usr.bin/mandoc/db/run/man/man1/third.1 + +>>> badarch0 +/usr/obj/regress/usr.bin/mandoc/db/run/man/man1/amd64/empty.1 + +>>> badarch +/usr/obj/regress/usr.bin/mandoc/db/run/man/man1/i386/empty.1 + +>>> baddesc0 +empty(1) - (NULL) + +>>> baddesc +empty(1) - no title +second, empty(1) - (NULL) +third, empty(1) - no title + +>>> badfile0 +/usr/obj/regress/usr.bin/mandoc/db/run/man/(NULL) + +>>> badfile +/usr/obj/regress/usr.bin/mandoc/db/run/man/man1/empty.1 +/usr/obj/regress/usr.bin/mandoc/db/run/man/(NULL) +/usr/obj/regress/usr.bin/mandoc/db/run/man/man1/third.1 diff --git a/regress/usr.bin/mandoc/db/out/badarch.dout b/regress/usr.bin/mandoc/db/out/badarch.dout new file mode 100644 index 00000000000..75fde7b575e --- /dev/null +++ b/regress/usr.bin/mandoc/db/out/badarch.dout @@ -0,0 +1,62 @@ +initial magic 0x3a7d0cdb +version 0x00000001 +macros offset 0x000000dc +end offset 0x00000200 +page count 3 +=== PAGES === +page name # [fh1t]empty +page sect # 1 +page arch # amd64 +page desc # no title +page file src # man1/amd64/empty.1 +page name # [fh1t]empty +page sect # 1 +page arch # i386 +page desc # no title +page file src # man1/i386/empty.1 +page name # [fh1t]empty +page sect # 1 +page arch # sgi +page desc # no title +page file src # man1/sgi/empty.1 +=== END OF PAGES === +macros count 36 +=== MACROS === +macro 00 entry count 0 +macro 01 entry count 0 +macro 02 entry count 0 +macro 03 entry count 0 +macro 04 entry count 0 +macro 05 entry count 0 +macro 06 entry count 0 +macro 07 entry count 0 +macro 08 entry count 0 +macro 09 entry count 0 +macro 10 entry count 0 +macro 11 entry count 0 +macro 12 entry count 0 +macro 13 entry count 0 +macro 14 entry count 0 +macro 15 entry count 0 +macro 16 entry count 0 +macro 17 entry count 0 +macro 18 entry count 0 +macro 19 entry count 0 +macro 20 entry count 0 +macro 21 entry count 0 +macro 22 entry count 0 +macro 23 entry count 0 +macro 24 entry count 0 +macro 25 entry count 0 +macro 26 entry count 0 +macro 27 entry count 0 +macro 28 entry count 0 +macro 29 entry count 0 +macro 30 entry count 0 +macro 31 entry count 0 +macro 32 entry count 0 +macro 33 entry count 0 +macro 34 entry count 0 +macro 35 entry count 0 +=== END OF MACROS === +final magic 0x3a7d0cdb diff --git a/regress/usr.bin/mandoc/db/out/badarch0.dout b/regress/usr.bin/mandoc/db/out/badarch0.dout new file mode 100644 index 00000000000..368fb842140 --- /dev/null +++ b/regress/usr.bin/mandoc/db/out/badarch0.dout @@ -0,0 +1,62 @@ +initial magic 0x3a7d0cdb +version 0x00000001 +macros offset 0x000000dc +end offset 0x00000200 +page count 3 +=== PAGES === +page name # [fh1t]empty +page sect # 1 +page arch # (NULL) +page desc # no title +page file src # man1/amd64/empty.1 +page name # [fh1t]empty +page sect # 1 +page arch # i386 +page desc # no title +page file src # man1/i386/empty.1 +page name # [fh1t]empty +page sect # 1 +page arch # sgi +page desc # no title +page file src # man1/sgi/empty.1 +=== END OF PAGES === +macros count 36 +=== MACROS === +macro 00 entry count 0 +macro 01 entry count 0 +macro 02 entry count 0 +macro 03 entry count 0 +macro 04 entry count 0 +macro 05 entry count 0 +macro 06 entry count 0 +macro 07 entry count 0 +macro 08 entry count 0 +macro 09 entry count 0 +macro 10 entry count 0 +macro 11 entry count 0 +macro 12 entry count 0 +macro 13 entry count 0 +macro 14 entry count 0 +macro 15 entry count 0 +macro 16 entry count 0 +macro 17 entry count 0 +macro 18 entry count 0 +macro 19 entry count 0 +macro 20 entry count 0 +macro 21 entry count 0 +macro 22 entry count 0 +macro 23 entry count 0 +macro 24 entry count 0 +macro 25 entry count 0 +macro 26 entry count 0 +macro 27 entry count 0 +macro 28 entry count 0 +macro 29 entry count 0 +macro 30 entry count 0 +macro 31 entry count 0 +macro 32 entry count 0 +macro 33 entry count 0 +macro 34 entry count 0 +macro 35 entry count 0 +=== END OF MACROS === +final magic 0x3a7d0cdb diff --git a/regress/usr.bin/mandoc/db/out/baddesc.dout b/regress/usr.bin/mandoc/db/out/baddesc.dout new file mode 100644 index 00000000000..57e544b97fc --- /dev/null +++ b/regress/usr.bin/mandoc/db/out/baddesc.dout @@ -0,0 +1,59 @@ +initial magic 0x3a7d0cdb +version 0x00000001 +macros offset 0x000000cc +end offset 0x000001f0 +page count 3 +=== PAGES === +page name # [fh1t]empty +page sect # 1 +page desc # no title +page file src # man1/empty.1 +page name # [f]second # [h1t]empty +page sect # 1 +page desc # no title +page file src # man1/second.1 +page name # [f]third # [h1t]empty +page sect # 1 +page desc # no title +page file src # man1/third.1 +=== END OF PAGES === +macros count 36 +=== MACROS === +macro 00 entry count 0 +macro 01 entry count 0 +macro 02 entry count 0 +macro 03 entry count 0 +macro 04 entry count 0 +macro 05 entry count 0 +macro 06 entry count 0 +macro 07 entry count 0 +macro 08 entry count 0 +macro 09 entry count 0 +macro 10 entry count 0 +macro 11 entry count 0 +macro 12 entry count 0 +macro 13 entry count 0 +macro 14 entry count 0 +macro 15 entry count 0 +macro 16 entry count 0 +macro 17 entry count 0 +macro 18 entry count 0 +macro 19 entry count 0 +macro 20 entry count 0 +macro 21 entry count 0 +macro 22 entry count 0 +macro 23 entry count 0 +macro 24 entry count 0 +macro 25 entry count 0 +macro 26 entry count 0 +macro 27 entry count 0 +macro 28 entry count 0 +macro 29 entry count 0 +macro 30 entry count 0 +macro 31 entry count 0 +macro 32 entry count 0 +macro 33 entry count 0 +macro 34 entry count 0 +macro 35 entry count 0 +=== END OF MACROS === +final magic 0x3a7d0cdb diff --git a/regress/usr.bin/mandoc/db/out/baddesc0.dout b/regress/usr.bin/mandoc/db/out/baddesc0.dout new file mode 100644 index 00000000000..e7e393815b9 --- /dev/null +++ b/regress/usr.bin/mandoc/db/out/baddesc0.dout @@ -0,0 +1,51 @@ +initial magic 0x3a7d0cdb +version 0x00000001 +macros offset 0x0000004c +end offset 0x00000170 +page count 1 +=== PAGES === +page name # [fh1t]empty +page sect # 1 +page desc # (NULL) +page file src # man1/empty.1 +=== END OF PAGES === +macros count 36 +=== MACROS === +macro 00 entry count 0 +macro 01 entry count 0 +macro 02 entry count 0 +macro 03 entry count 0 +macro 04 entry count 0 +macro 05 entry count 0 +macro 06 entry count 0 +macro 07 entry count 0 +macro 08 entry count 0 +macro 09 entry count 0 +macro 10 entry count 0 +macro 11 entry count 0 +macro 12 entry count 0 +macro 13 entry count 0 +macro 14 entry count 0 +macro 15 entry count 0 +macro 16 entry count 0 +macro 17 entry count 0 +macro 18 entry count 0 +macro 19 entry count 0 +macro 20 entry count 0 +macro 21 entry count 0 +macro 22 entry count 0 +macro 23 entry count 0 +macro 24 entry count 0 +macro 25 entry count 0 +macro 26 entry count 0 +macro 27 entry count 0 +macro 28 entry count 0 +macro 29 entry count 0 +macro 30 entry count 0 +macro 31 entry count 0 +macro 32 entry count 0 +macro 33 entry count 0 +macro 34 entry count 0 +macro 35 entry count 0 +=== END OF MACROS === +final magic 0x3a7d0cdb diff --git a/regress/usr.bin/mandoc/db/out/badfile.dout b/regress/usr.bin/mandoc/db/out/badfile.dout new file mode 100644 index 00000000000..57e544b97fc --- /dev/null +++ b/regress/usr.bin/mandoc/db/out/badfile.dout @@ -0,0 +1,59 @@ +initial magic 0x3a7d0cdb +version 0x00000001 +macros offset 0x000000cc +end offset 0x000001f0 +page count 3 +=== PAGES === +page name # [fh1t]empty +page sect # 1 +page desc # no title +page file src # man1/empty.1 +page name # [f]second # [h1t]empty +page sect # 1 +page desc # no title +page file src # man1/second.1 +page name # [f]third # [h1t]empty +page sect # 1 +page desc # no title +page file src # man1/third.1 +=== END OF PAGES === +macros count 36 +=== MACROS === +macro 00 entry count 0 +macro 01 entry count 0 +macro 02 entry count 0 +macro 03 entry count 0 +macro 04 entry count 0 +macro 05 entry count 0 +macro 06 entry count 0 +macro 07 entry count 0 +macro 08 entry count 0 +macro 09 entry count 0 +macro 10 entry count 0 +macro 11 entry count 0 +macro 12 entry count 0 +macro 13 entry count 0 +macro 14 entry count 0 +macro 15 entry count 0 +macro 16 entry count 0 +macro 17 entry count 0 +macro 18 entry count 0 +macro 19 entry count 0 +macro 20 entry count 0 +macro 21 entry count 0 +macro 22 entry count 0 +macro 23 entry count 0 +macro 24 entry count 0 +macro 25 entry count 0 +macro 26 entry count 0 +macro 27 entry count 0 +macro 28 entry count 0 +macro 29 entry count 0 +macro 30 entry count 0 +macro 31 entry count 0 +macro 32 entry count 0 +macro 33 entry count 0 +macro 34 entry count 0 +macro 35 entry count 0 +=== END OF MACROS === +final magic 0x3a7d0cdb diff --git a/regress/usr.bin/mandoc/db/out/badfile0.dout b/regress/usr.bin/mandoc/db/out/badfile0.dout new file mode 100644 index 00000000000..2bab93d4c9b --- /dev/null +++ b/regress/usr.bin/mandoc/db/out/badfile0.dout @@ -0,0 +1,51 @@ +initial magic 0x3a7d0cdb +version 0x00000001 +macros offset 0x0000004c +end offset 0x00000170 +page count 1 +=== PAGES === +page name # [fh1t]empty +page sect # 1 +page desc # no title +page file # (NULL) +=== END OF PAGES === +macros count 36 +=== MACROS === +macro 00 entry count 0 +macro 01 entry count 0 +macro 02 entry count 0 +macro 03 entry count 0 +macro 04 entry count 0 +macro 05 entry count 0 +macro 06 entry count 0 +macro 07 entry count 0 +macro 08 entry count 0 +macro 09 entry count 0 +macro 10 entry count 0 +macro 11 entry count 0 +macro 12 entry count 0 +macro 13 entry count 0 +macro 14 entry count 0 +macro 15 entry count 0 +macro 16 entry count 0 +macro 17 entry count 0 +macro 18 entry count 0 +macro 19 entry count 0 +macro 20 entry count 0 +macro 21 entry count 0 +macro 22 entry count 0 +macro 23 entry count 0 +macro 24 entry count 0 +macro 25 entry count 0 +macro 26 entry count 0 +macro 27 entry count 0 +macro 28 entry count 0 +macro 29 entry count 0 +macro 30 entry count 0 +macro 31 entry count 0 +macro 32 entry count 0 +macro 33 entry count 0 +macro 34 entry count 0 +macro 35 entry count 0 +=== END OF MACROS === +final magic 0x3a7d0cdb diff --git a/regress/usr.bin/mandoc/db/out/badname.dout b/regress/usr.bin/mandoc/db/out/badname.dout new file mode 100644 index 00000000000..57e544b97fc --- /dev/null +++ b/regress/usr.bin/mandoc/db/out/badname.dout @@ -0,0 +1,59 @@ +initial magic 0x3a7d0cdb +version 0x00000001 +macros offset 0x000000cc +end offset 0x000001f0 +page count 3 +=== PAGES === +page name # [fh1t]empty +page sect # 1 +page desc # no title +page file src # man1/empty.1 +page name # [f]second # [h1t]empty +page sect # 1 +page desc # no title +page file src # man1/second.1 +page name # [f]third # [h1t]empty +page sect # 1 +page desc # no title +page file src # man1/third.1 +=== END OF PAGES === +macros count 36 +=== MACROS === +macro 00 entry count 0 +macro 01 entry count 0 +macro 02 entry count 0 +macro 03 entry count 0 +macro 04 entry count 0 +macro 05 entry count 0 +macro 06 entry count 0 +macro 07 entry count 0 +macro 08 entry count 0 +macro 09 entry count 0 +macro 10 entry count 0 +macro 11 entry count 0 +macro 12 entry count 0 +macro 13 entry count 0 +macro 14 entry count 0 +macro 15 entry count 0 +macro 16 entry count 0 +macro 17 entry count 0 +macro 18 entry count 0 +macro 19 entry count 0 +macro 20 entry count 0 +macro 21 entry count 0 +macro 22 entry count 0 +macro 23 entry count 0 +macro 24 entry count 0 +macro 25 entry count 0 +macro 26 entry count 0 +macro 27 entry count 0 +macro 28 entry count 0 +macro 29 entry count 0 +macro 30 entry count 0 +macro 31 entry count 0 +macro 32 entry count 0 +macro 33 entry count 0 +macro 34 entry count 0 +macro 35 entry count 0 +=== END OF MACROS === +final magic 0x3a7d0cdb diff --git a/regress/usr.bin/mandoc/db/out/badname0.dout b/regress/usr.bin/mandoc/db/out/badname0.dout new file mode 100644 index 00000000000..dd7ce10648a --- /dev/null +++ b/regress/usr.bin/mandoc/db/out/badname0.dout @@ -0,0 +1,51 @@ +initial magic 0x3a7d0cdb +version 0x00000001 +macros offset 0x0000004c +end offset 0x00000170 +page count 1 +=== PAGES === +page name # (NULL) +page sect # 1 +page desc # no title +page file src # man1/empty.1 +=== END OF PAGES === +macros count 36 +=== MACROS === +macro 00 entry count 0 +macro 01 entry count 0 +macro 02 entry count 0 +macro 03 entry count 0 +macro 04 entry count 0 +macro 05 entry count 0 +macro 06 entry count 0 +macro 07 entry count 0 +macro 08 entry count 0 +macro 09 entry count 0 +macro 10 entry count 0 +macro 11 entry count 0 +macro 12 entry count 0 +macro 13 entry count 0 +macro 14 entry count 0 +macro 15 entry count 0 +macro 16 entry count 0 +macro 17 entry count 0 +macro 18 entry count 0 +macro 19 entry count 0 +macro 20 entry count 0 +macro 21 entry count 0 +macro 22 entry count 0 +macro 23 entry count 0 +macro 24 entry count 0 +macro 25 entry count 0 +macro 26 entry count 0 +macro 27 entry count 0 +macro 28 entry count 0 +macro 29 entry count 0 +macro 30 entry count 0 +macro 31 entry count 0 +macro 32 entry count 0 +macro 33 entry count 0 +macro 34 entry count 0 +macro 35 entry count 0 +=== END OF MACROS === +final magic 0x3a7d0cdb diff --git a/regress/usr.bin/mandoc/db/out/badsect.dout b/regress/usr.bin/mandoc/db/out/badsect.dout new file mode 100644 index 00000000000..57e544b97fc --- /dev/null +++ b/regress/usr.bin/mandoc/db/out/badsect.dout @@ -0,0 +1,59 @@ +initial magic 0x3a7d0cdb +version 0x00000001 +macros offset 0x000000cc +end offset 0x000001f0 +page count 3 +=== PAGES === +page name # [fh1t]empty +page sect # 1 +page desc # no title +page file src # man1/empty.1 +page name # [f]second # [h1t]empty +page sect # 1 +page desc # no title +page file src # man1/second.1 +page name # [f]third # [h1t]empty +page sect # 1 +page desc # no title +page file src # man1/third.1 +=== END OF PAGES === +macros count 36 +=== MACROS === +macro 00 entry count 0 +macro 01 entry count 0 +macro 02 entry count 0 +macro 03 entry count 0 +macro 04 entry count 0 +macro 05 entry count 0 +macro 06 entry count 0 +macro 07 entry count 0 +macro 08 entry count 0 +macro 09 entry count 0 +macro 10 entry count 0 +macro 11 entry count 0 +macro 12 entry count 0 +macro 13 entry count 0 +macro 14 entry count 0 +macro 15 entry count 0 +macro 16 entry count 0 +macro 17 entry count 0 +macro 18 entry count 0 +macro 19 entry count 0 +macro 20 entry count 0 +macro 21 entry count 0 +macro 22 entry count 0 +macro 23 entry count 0 +macro 24 entry count 0 +macro 25 entry count 0 +macro 26 entry count 0 +macro 27 entry count 0 +macro 28 entry count 0 +macro 29 entry count 0 +macro 30 entry count 0 +macro 31 entry count 0 +macro 32 entry count 0 +macro 33 entry count 0 +macro 34 entry count 0 +macro 35 entry count 0 +=== END OF MACROS === +final magic 0x3a7d0cdb diff --git a/regress/usr.bin/mandoc/db/out/badsect0.dout b/regress/usr.bin/mandoc/db/out/badsect0.dout new file mode 100644 index 00000000000..56316383cf8 --- /dev/null +++ b/regress/usr.bin/mandoc/db/out/badsect0.dout @@ -0,0 +1,51 @@ +initial magic 0x3a7d0cdb +version 0x00000001 +macros offset 0x0000004c +end offset 0x00000170 +page count 1 +=== PAGES === +page name # [fh1t]empty +page sect # (NULL) +page desc # no title +page file src # man1/empty.1 +=== END OF PAGES === +macros count 36 +=== MACROS === +macro 00 entry count 0 +macro 01 entry count 0 +macro 02 entry count 0 +macro 03 entry count 0 +macro 04 entry count 0 +macro 05 entry count 0 +macro 06 entry count 0 +macro 07 entry count 0 +macro 08 entry count 0 +macro 09 entry count 0 +macro 10 entry count 0 +macro 11 entry count 0 +macro 12 entry count 0 +macro 13 entry count 0 +macro 14 entry count 0 +macro 15 entry count 0 +macro 16 entry count 0 +macro 17 entry count 0 +macro 18 entry count 0 +macro 19 entry count 0 +macro 20 entry count 0 +macro 21 entry count 0 +macro 22 entry count 0 +macro 23 entry count 0 +macro 24 entry count 0 +macro 25 entry count 0 +macro 26 entry count 0 +macro 27 entry count 0 +macro 28 entry count 0 +macro 29 entry count 0 +macro 30 entry count 0 +macro 31 entry count 0 +macro 32 entry count 0 +macro 33 entry count 0 +macro 34 entry count 0 +macro 35 entry count 0 +=== END OF MACROS === +final magic 0x3a7d0cdb diff --git a/regress/usr.bin/mandoc/db/out/threearch.dout b/regress/usr.bin/mandoc/db/out/threearch.dout new file mode 100644 index 00000000000..75fde7b575e --- /dev/null +++ b/regress/usr.bin/mandoc/db/out/threearch.dout @@ -0,0 +1,62 @@ +initial magic 0x3a7d0cdb +version 0x00000001 +macros offset 0x000000dc +end offset 0x00000200 +page count 3 +=== PAGES === +page name # [fh1t]empty +page sect # 1 +page arch # amd64 +page desc # no title +page file src # man1/amd64/empty.1 +page name # [fh1t]empty +page sect # 1 +page arch # i386 +page desc # no title +page file src # man1/i386/empty.1 +page name # [fh1t]empty +page sect # 1 +page arch # sgi +page desc # no title +page file src # man1/sgi/empty.1 +=== END OF PAGES === +macros count 36 +=== MACROS === +macro 00 entry count 0 +macro 01 entry count 0 +macro 02 entry count 0 +macro 03 entry count 0 +macro 04 entry count 0 +macro 05 entry count 0 +macro 06 entry count 0 +macro 07 entry count 0 +macro 08 entry count 0 +macro 09 entry count 0 +macro 10 entry count 0 +macro 11 entry count 0 +macro 12 entry count 0 +macro 13 entry count 0 +macro 14 entry count 0 +macro 15 entry count 0 +macro 16 entry count 0 +macro 17 entry count 0 +macro 18 entry count 0 +macro 19 entry count 0 +macro 20 entry count 0 +macro 21 entry count 0 +macro 22 entry count 0 +macro 23 entry count 0 +macro 24 entry count 0 +macro 25 entry count 0 +macro 26 entry count 0 +macro 27 entry count 0 +macro 28 entry count 0 +macro 29 entry count 0 +macro 30 entry count 0 +macro 31 entry count 0 +macro 32 entry count 0 +macro 33 entry count 0 +macro 34 entry count 0 +macro 35 entry count 0 +=== END OF MACROS === +final magic 0x3a7d0cdb diff --git a/regress/usr.bin/mandoc/db/run/Makefile b/regress/usr.bin/mandoc/db/run/Makefile index b88ef54bbcd..fac8fd3c6f9 100644 --- a/regress/usr.bin/mandoc/db/run/Makefile +++ b/regress/usr.bin/mandoc/db/run/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.2 2016/08/04 09:18:53 schwarze Exp $ +# $OpenBSD: Makefile,v 1.3 2016/08/30 22:20:03 schwarze Exp $ # # Copyright (c) 2016 Ingo Schwarze # @@ -14,54 +14,62 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -OUT_TESTS = empty onepage twopages threepages threemacros -OUT_TESTS += sortpages sortpages_rev so so_rev sortnames twosect twoarch -OUT_TESTS += fn in va sh xr -BOTH_TESTS = padipage padfpage padmpage padmacros padimacro padmmacro -BOTH_TESTS += padientry padfentry padmentry padfmagic -ERR_TESTS = nonexistent short badimagic badversion badmacrosp badendp -ERR_TESTS += badnpages badnmacros badmacrop badfmagic -ALL_TESTS = ${OUT_TESTS} ${BOTH_TESTS} ${ERR_TESTS} +DO_MO_TESTS = onepage twopages threepages threemacros +DO_MO_TESTS += sortpages sortpages_rev so so_rev sortnames +DO_MO_TESTS += twosect twoarch threearch fn in va sh xr +DO_MOE_TESTS = empty +DOE_M_TESTS = padipage padfpage padmpage +DOE_M_TESTS += padmacros padimacro padmmacro +DOE_M_TESTS += padientry padfentry padmentry padfmagic +DOE_MOE_TESTS = badname0 badname badsect0 badsect badarch0 badarch +DOE_MOE_TESTS += baddesc0 baddesc badfile0 badfile +DE_M_TESTS = nonexistent short badimagic badversion badmacrosp badendp +DE_M_TESTS += badnpages badnmacros badmacrop badfmagic + +DO_TESTS = ${DO_MO_TESTS} ${DO_MOE_TESTS} +DOE_TESTS = ${DOE_M_TESTS} ${DOE_MOE_TESTS} +DE_TESTS = ${DE_M_TESTS} +DOB_TESTS = ${DO_TESTS} ${DOE_TESTS} +DEB_TESTS = ${DOE_TESTS} ${DE_TESTS} +MOB_TESTS = ${DO_MO_TESTS} ${DO_MOE_TESTS} ${DOE_MOE_TESTS} +MEB_TESTS = ${DO_MOE_TESTS} ${DOE_MOE_TESTS} +ALL_TESTS = ${DO_TESTS} ${DOE_TESTS} ${DE_TESTS} REGRESS_TARGETS = ${ALL_TESTS} diff.derr diff.mout diff.merr CLEANFILES = ${ALL_TESTS:C/$/.db/} CLEANFILES += ${ALL_TESTS:C/$/.dout/} ${ALL_TESTS:C/$/.derr/} all.derr -CLEANFILES += ${OUT_TESTS:C/$/.mout/} all.mout empty.merr +CLEANFILES += ${MOB_TESTS:C/$/.mout/} all.mout +CLEANFILES += ${MEB_TESTS:C/$/.merr/} all.merr # === MAIN REGRESSION TARGETS ========================================== -.for NAME in ${OUT_TESTS} +.for NAME in ${DO_TESTS} ${NAME}: ${NAME}.dout ${NAME}.derr - test \! -s ${NAME}.derr - @echo diffing ${NAME}.dout + @test \! -s ${NAME}.derr @diff -u ${.CURDIR}/../out/${NAME}.dout ${NAME}.dout .endfor -.for NAME in ${BOTH_TESTS} +.for NAME in ${DOE_TESTS} ${NAME}: ${NAME}.dout ${NAME}.derr - test -s ${NAME}.derr - @echo diffing ${NAME}.dout + @test -s ${NAME}.derr @diff -u ${.CURDIR}/../out/${NAME}.dout ${NAME}.dout .endfor -.for NAME in ${ERR_TESTS} +.for NAME in ${DE_TESTS} ${NAME}: ${NAME}.dout ${NAME}.derr - test -s ${NAME}.derr - test \! -s ${NAME}.dout + @test -s ${NAME}.derr + @test \! -s ${NAME}.dout .endfor diff.derr: all.derr - @echo diffing all.derr @diff -u ${.CURDIR}/../out/all.derr all.derr diff.mout: all.mout - @echo diffing all.mout @diff -u ${.CURDIR}/../out/all.mout all.mout -diff.merr: empty.merr - @echo diffing empty.merr - @diff -u ${.CURDIR}/../out/empty.merr empty.merr +diff.merr: all.merr + @diff -u ${.CURDIR}/../out/all.merr all.merr .PHONY: ${REGRESS_TARGETS} @@ -73,28 +81,25 @@ cleandir_local: # === RUNNING DBM_DUMP ================================================= -.for NAME in ${OUT_TESTS} ${BOTH_TESTS} +.for NAME in ${DOB_TESTS} ${NAME}.dout ${NAME}.derr: dbm_dump ${NAME}.db - ./dbm_dump ${NAME}.db > ${NAME}.dout 2> ${NAME}.derr + @./dbm_dump ${NAME}.db > ${NAME}.dout 2> ${NAME}.derr .endfor -.for NAME in ${ERR_TESTS} +.for NAME in ${DE_TESTS} ${NAME}.dout ${NAME}.derr: dbm_dump ${NAME}.db - @echo dumping ${NAME}.db @if ./dbm_dump ${NAME}.db > ${NAME}.dout 2> ${NAME}.derr; \ then false; else true; fi .endfor -all.derr: ${BOTH_TESTS:C/$/.derr/} ${ERR_TESTS:C/$/.derr/} - @echo assembling $@ - @for f in ${BOTH_TESTS} ${ERR_TESTS}; \ +all.derr: ${DEB_TESTS:C/$/.derr/} + @for f in ${DEB_TESTS}; \ do printf "\n>>> $$f\n"; cat $$f.derr; done > $@ # === RUNNING MAKEWHATIS AND MAN ======================================= empty.db empty.mout empty.merr: - @echo making empty.db @rm -rf man @mkdir man @makewhatis man @@ -104,7 +109,6 @@ empty.db empty.mout empty.merr: @rmdir man onepage.db onepage.mout: ${.CURDIR}/../man/empty.1 - @echo making onepage.db @rm -rf man @mkdir -p man/man1 @cp ${.CURDIR}/../man/empty.1 man/man1/ @@ -231,6 +235,22 @@ twoarch.db twoarch.mout: ${.CURDIR}/../man/empty.1 @mv man/mandoc.db twoarch.db @rm -rf man +threearch.db threearch.mout: ${.CURDIR}/../man/empty.1 + @rm -rf man + @mkdir -p man/man1/amd64 + @mkdir -p man/man1/i386 + @mkdir -p man/man1/sgi + @cp ${.CURDIR}/../man/empty.1 man/man1/amd64/ + @cp ${.CURDIR}/../man/empty.1 man/man1/i386/ + @cp ${.CURDIR}/../man/empty.1 man/man1/sgi/ + @makewhatis man + @(echo "> amd64"; man -wM man -S amd64 empty | sed 's#.*/man/##'; \ + echo "> i386"; man -wM man -S i386 empty | sed 's#.*/man/##'; \ + echo "> sgi"; man -wM man -S sgi empty | sed 's#.*/man/##') \ + > threearch.mout + @mv man/mandoc.db threearch.db + @rm -rf man + fn.db fn.mout: ${.CURDIR}/../man/fn.3 @rm -rf man @mkdir -p man/man3 @@ -240,7 +260,7 @@ fn.db fn.mout: ${.CURDIR}/../man/fn.3 echo "> fn_func"; man -kwM man Fn=fn_func | sed 's#.*/man/##'; \ echo "> fn_arg"; man -kwM man Fa=fn_arg | sed 's#.*/man/##'; \ echo "> fo_type"; man -kwM man Ft=fo_type | sed 's#.*/man/##'; \ - echo "> fo_func"; man -kwM man Fn=fo_func | sed 's#.*/man/##'; \ + echo "> fo_func"; man -kwM man Fn=fo_func 2>&1 | sed 's#.*/man/##'; \ echo "> fo_arg"; man -kwM man Fa=fo_arg | sed 's#.*/man/##') \ > fn.mout @mv man/mandoc.db fn.db @@ -293,79 +313,183 @@ xr.db xr.mout: ${.CURDIR}/../man/xr.1 @mv man/mandoc.db xr.db @rm -rf man -all.mout: ${OUT_TESTS:C/$/.mout/} - @echo assembling all.mout - @for f in ${OUT_TESTS}; do printf "\n>>> $$f\n"; \ - test -e $$f.mout && cat $$f.mout || true; done > $@ +badname0.mout badname0.merr: badname0.db + @rm -rf man + @mkdir man + @cp badname0.db man/mandoc.db + @if man -wM man empty > badname0.mout 2> badname0.merr; \ + then false; else test $$? -eq 5; fi + @rm -rf man + +badname.mout badname.merr: badname.db + @rm -rf man + @mkdir man + @cp badname.db man/mandoc.db + @man -wM man empty > badname.mout 2> badname.merr + @rm -rf man + +badsect0.mout badsect0.merr: badsect0.db + @rm -rf man + @mkdir man + @cp badsect0.db man/mandoc.db + @if man -wM man -s 1 empty > badsect0.mout 2> badsect0.merr; \ + then false; else test $$? -eq 5; fi + @rm -rf man + +badsect.mout badsect.merr: badsect.db + @rm -rf man + @mkdir man + @cp badsect.db man/mandoc.db + @man -wM man -s 1 empty > badsect.mout 2> badsect.merr + @rm -rf man + +badarch0.mout badarch0.merr: badarch0.db + @rm -rf man + @mkdir man + @cp badarch0.db man/mandoc.db + @man -wM man -S amd64 empty > badarch0.mout 2> badarch0.merr + @rm -rf man + +badarch.mout badarch.merr: badarch.db + @rm -rf man + @mkdir man + @cp badarch.db man/mandoc.db + @man -wM man -S i386 empty > badarch.mout 2> badarch.merr + @rm -rf man + +baddesc0.mout baddesc0.merr: baddesc0.db + @rm -rf man + @mkdir man + @cp baddesc0.db man/mandoc.db + @man -kM man empty > baddesc0.mout 2> baddesc0.merr + @rm -rf man + +baddesc.mout baddesc0.merr: baddesc.db + @rm -rf man + @mkdir man + @cp baddesc.db man/mandoc.db + @man -kM man empty > baddesc.mout 2> baddesc.merr + @rm -rf man + +badfile0.mout badfile0.merr: badfile0.db + @rm -rf man + @mkdir man + @cp badfile0.db man/mandoc.db + @man -wM man empty > badfile0.mout 2> badfile0.merr + @rm -rf man + +badfile.mout badfile.merr: badfile.db + @rm -rf man + @mkdir man + @cp badfile.db man/mandoc.db + @man -wM man empty > badfile.mout 2> badfile.merr + @rm -rf man + +all.mout: ${MOB_TESTS:C/$/.mout/} + @for f in ${MOB_TESTS}; \ + do printf "\n>>> $$f\n"; cat $$f.mout || true; done > $@ + +all.merr: ${MEB_TESTS:C/$/.merr/} + @for f in ${MEB_TESTS}; \ + do printf "\n>>> $$f\n"; cat $$f.merr || true; done > $@ # === RUNNING BINEDIT ================================================== padipage.db: binedit twopages.db - ./binedit c16rw1f < twopages.db > $@ + @./binedit c16rw1f < twopages.db > $@ padfpage.db: binedit twopages.db - ./binedit c16rw1s20c20w0w0w0w0w0f < twopages.db > $@ + @./binedit c16rw1s20c20w0w0w0w0w0f < twopages.db > $@ padmpage.db: binedit threepages.db - ./binedit c16rw2c20s20c20w0w0w0w0w0f < threepages.db > $@ + @./binedit c16rw2c20s20c20w0w0w0w0w0f < threepages.db > $@ + +badname0.db: binedit onepage.db + @./binedit c20rw-1f < onepage.db > $@ + +badname.db: binedit threepages.db + @./binedit c40rw-1f < threepages.db > $@ + +badsect0.db: binedit onepage.db + @./binedit c24rw-1f < onepage.db > $@ + +badsect.db: binedit threepages.db + @./binedit c44rw-1f < threepages.db > $@ + +badarch0.db: binedit threearch.db + @./binedit c28rw-1f < threearch.db > $@ + +badarch.db: binedit threearch.db + @./binedit c48rw-1f < threearch.db > $@ + +baddesc0.db: binedit onepage.db + @./binedit c32rw-1f < onepage.db > $@ + +baddesc.db: binedit threepages.db + @./binedit c52rw-1f < threepages.db > $@ + +badfile0.db: binedit onepage.db + @./binedit c36rw-1f < onepage.db > $@ + +badfile.db: binedit threepages.db + @./binedit c56rw-1f < threepages.db > $@ padmacros.db: binedit onepage.db - ./binedit c16rw0f < onepage.db > $@ + @./binedit c16rw0f < onepage.db > $@ padimacro.db: binedit empty.db - ./binedit c8rdwri4wac4s4c136rwi4ww0f < empty.db > $@ + @./binedit c8rdwri4wac4s4c136rwi4ww0f < empty.db > $@ padmmacro.db: binedit empty.db - ./binedit c8rdwri4wac8s4c132rwi4ww0f < empty.db > $@ + @./binedit c8rdwri4wac8s4c132rwi4ww0f < empty.db > $@ padientry.db: binedit threemacros.db - ./binedit c8rdwac4rdwarw2f < threemacros.db > $@ + @./binedit c8rdwac4rdwarw2f < threemacros.db > $@ padfentry.db: binedit threemacros.db - ./binedit c8rdwac4rdwarw2s8c16w0w0f < threemacros.db > $@ + @./binedit c8rdwac4rdwarw2s8c16w0w0f < threemacros.db > $@ padmentry.db: binedit threemacros.db - ./binedit c8rdwac4rdwarw2c8s8c8w0w0f < threemacros.db > $@ + @./binedit c8rdwac4rdwarw2c8s8c8w0w0f < threemacros.db > $@ padfmagic.db: binedit empty.db - ./binedit c12rdi4waw0f < empty.db > $@ + @./binedit c12rdi4waw0f < empty.db > $@ nonexistent.db: - rm -rf nonexistent.db + @rm -rf nonexistent.db short.db: - echo 'sho' > $@ + @echo 'sho' > $@ badimagic.db: binedit empty.db - ./binedit riwf < empty.db > $@ + @./binedit riwf < empty.db > $@ badversion.db: binedit empty.db - ./binedit c4riwf < empty.db > $@ + @./binedit c4riwf < empty.db > $@ badmacrosp.db: binedit empty.db - ./binedit c8rw1000f < empty.db > $@ + @./binedit c8rw1000f < empty.db > $@ badendp.db: binedit empty.db - ./binedit c12riwf < empty.db > $@ + @./binedit c12riwf < empty.db > $@ badnpages.db: binedit empty.db - ./binedit c16rw-1f < empty.db > $@ + @./binedit c16rw-1f < empty.db > $@ badnmacros.db: binedit empty.db - ./binedit c8rdwariwf < empty.db > $@ + @./binedit c8rdwariwf < empty.db > $@ badmacrop.db: binedit empty.db - ./binedit c8rdwac4rw1000f < empty.db > $@ + @./binedit c8rdwac4rw1000f < empty.db > $@ badfmagic.db: binedit empty.db - ./binedit c12rdwariwf < empty.db > $@ + @./binedit c12rdwariwf < empty.db > $@ # === GETTING ACCESS TO THE UTILITIES ================================== binedit dbm_dump makeinodes: - @echo installing $@ @if [ -x ${.CURDIR}/../$@/obj/$@ ]; \ then ln -s ${.CURDIR}/../$@/obj/$@; \ elif [ -x ${.CURDIR}/../$@/$@ ]; \