From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/7] docparse: Add tests
Date: Mon, 18 Oct 2021 17:47:54 +0200 [thread overview]
Message-ID: <20211018154800.11013-3-chrubis@suse.cz> (raw)
In-Reply-To: <20211018154800.11013-1-chrubis@suse.cz>
This add a simple tests for the docparse parser.
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
docparse/tests/empty_struct.c | 2 ++
docparse/tests/empty_struct.c.out | 3 +++
docparse/tests/expand_flags.c | 3 +++
docparse/tests/expand_flags.c.out | 6 ++++++
docparse/tests/include.c | 5 +++++
docparse/tests/include.c.out | 4 ++++
docparse/tests/include.h | 1 +
docparse/tests/macro.c | 5 +++++
docparse/tests/macro.c.out | 4 ++++
docparse/tests/multiline_macro.c | 6 ++++++
docparse/tests/multiline_macro.c.out | 4 ++++
docparse/tests/tags.c | 7 +++++++
docparse/tests/tags.c.out | 13 +++++++++++++
docparse/tests/test.sh | 18 ++++++++++++++++++
14 files changed, 81 insertions(+)
create mode 100644 docparse/tests/empty_struct.c
create mode 100644 docparse/tests/empty_struct.c.out
create mode 100644 docparse/tests/expand_flags.c
create mode 100644 docparse/tests/expand_flags.c.out
create mode 100644 docparse/tests/include.c
create mode 100644 docparse/tests/include.c.out
create mode 100644 docparse/tests/include.h
create mode 100644 docparse/tests/macro.c
create mode 100644 docparse/tests/macro.c.out
create mode 100644 docparse/tests/multiline_macro.c
create mode 100644 docparse/tests/multiline_macro.c.out
create mode 100644 docparse/tests/tags.c
create mode 100644 docparse/tests/tags.c.out
create mode 100755 docparse/tests/test.sh
diff --git a/docparse/tests/empty_struct.c b/docparse/tests/empty_struct.c
new file mode 100644
index 000000000..e5d986413
--- /dev/null
+++ b/docparse/tests/empty_struct.c
@@ -0,0 +1,2 @@
+static struct tst_test test = {
+};
diff --git a/docparse/tests/empty_struct.c.out b/docparse/tests/empty_struct.c.out
new file mode 100644
index 000000000..9f49f5332
--- /dev/null
+++ b/docparse/tests/empty_struct.c.out
@@ -0,0 +1,3 @@
+ "empty_struct": {
+ "fname": "empty_struct.c"
+ }
\ No newline at end of file
diff --git a/docparse/tests/expand_flags.c b/docparse/tests/expand_flags.c
new file mode 100644
index 000000000..64f6da64e
--- /dev/null
+++ b/docparse/tests/expand_flags.c
@@ -0,0 +1,3 @@
+static struct tst_test test = {
+ .all_filesystems = 1,
+};
diff --git a/docparse/tests/expand_flags.c.out b/docparse/tests/expand_flags.c.out
new file mode 100644
index 000000000..cd79dd296
--- /dev/null
+++ b/docparse/tests/expand_flags.c.out
@@ -0,0 +1,6 @@
+ "expand_flags": {
+ "all_filesystems": "1",
+ "needs_device": "1",
+ "needs_tmpdir": "1",
+ "fname": "expand_flags.c"
+ }
\ No newline at end of file
diff --git a/docparse/tests/include.c b/docparse/tests/include.c
new file mode 100644
index 000000000..7a35e3bb4
--- /dev/null
+++ b/docparse/tests/include.c
@@ -0,0 +1,5 @@
+#include "include.h"
+
+static struct tst_test test = {
+ .test_variants = TEST_VARIANTS,
+};
diff --git a/docparse/tests/include.c.out b/docparse/tests/include.c.out
new file mode 100644
index 000000000..b4ef1ccda
--- /dev/null
+++ b/docparse/tests/include.c.out
@@ -0,0 +1,4 @@
+ "include": {
+ "test_variants": "10",
+ "fname": "include.c"
+ }
\ No newline at end of file
diff --git a/docparse/tests/include.h b/docparse/tests/include.h
new file mode 100644
index 000000000..efa11d24f
--- /dev/null
+++ b/docparse/tests/include.h
@@ -0,0 +1 @@
+#define TEST_VARIANTS 10
diff --git a/docparse/tests/macro.c b/docparse/tests/macro.c
new file mode 100644
index 000000000..296da12f5
--- /dev/null
+++ b/docparse/tests/macro.c
@@ -0,0 +1,5 @@
+#define TEST_VARIANTS 10
+
+static struct tst_test test = {
+ .test_variants = TEST_VARIANTS,
+};
diff --git a/docparse/tests/macro.c.out b/docparse/tests/macro.c.out
new file mode 100644
index 000000000..0dc73d8ec
--- /dev/null
+++ b/docparse/tests/macro.c.out
@@ -0,0 +1,4 @@
+ "macro": {
+ "test_variants": "10",
+ "fname": "macro.c"
+ }
\ No newline at end of file
diff --git a/docparse/tests/multiline_macro.c b/docparse/tests/multiline_macro.c
new file mode 100644
index 000000000..2de58112b
--- /dev/null
+++ b/docparse/tests/multiline_macro.c
@@ -0,0 +1,6 @@
+#define TEST_VARIANTS \
+ 10
+
+static struct tst_test test = {
+ .test_variants = TEST_VARIANTS,
+};
diff --git a/docparse/tests/multiline_macro.c.out b/docparse/tests/multiline_macro.c.out
new file mode 100644
index 000000000..bafd037da
--- /dev/null
+++ b/docparse/tests/multiline_macro.c.out
@@ -0,0 +1,4 @@
+ "multiline_macro": {
+ "test_variants": "10",
+ "fname": "multiline_macro.c"
+ }
\ No newline at end of file
diff --git a/docparse/tests/tags.c b/docparse/tests/tags.c
new file mode 100644
index 000000000..ade3974ff
--- /dev/null
+++ b/docparse/tests/tags.c
@@ -0,0 +1,7 @@
+static struct tst_test test = {
+ .tags = (const struct tst_tag[]) {
+ {"tag-name-1", "tag-value-1"},
+ {"tag-name-2", "tag-value-2"},
+ {}
+ }
+};
diff --git a/docparse/tests/tags.c.out b/docparse/tests/tags.c.out
new file mode 100644
index 000000000..14cc14f1c
--- /dev/null
+++ b/docparse/tests/tags.c.out
@@ -0,0 +1,13 @@
+ "tags": {
+ "tags": [
+ [
+ "tag-name-1",
+ "tag-value-1"
+ ],
+ [
+ "tag-name-2",
+ "tag-value-2"
+ ]
+ ],
+ "fname": "tags.c"
+ }
\ No newline at end of file
diff --git a/docparse/tests/test.sh b/docparse/tests/test.sh
new file mode 100755
index 000000000..cc78dcae6
--- /dev/null
+++ b/docparse/tests/test.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+fail=0
+
+for i in *.c; do
+ ../docparse $i > out.tmp
+ if ! diff out.tmp $i.out &> /dev/null; then
+ echo "***"
+ echo "$i output differs!"
+ diff -u out.tmp $i.out
+ echo "***"
+ fail=1
+ fi
+done
+
+rm -f out.tmp
+
+exit $fail
--
2.32.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2021-10-18 15:47 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-18 15:47 [LTP] [PATCH 0/7] docparse improvements Cyril Hrubis
2021-10-18 15:47 ` [LTP] [PATCH 1/7] docparse: Implement #define and #include Cyril Hrubis
2021-10-29 8:26 ` Petr Vorel
2021-10-29 8:27 ` Petr Vorel
2021-10-18 15:47 ` Cyril Hrubis [this message]
2021-10-22 11:32 ` [LTP] [PATCH 2/7] docparse: Add tests Petr Vorel
2021-10-25 12:46 ` Cyril Hrubis
2021-10-25 20:00 ` Petr Vorel
2021-10-22 11:41 ` Petr Vorel
2021-10-25 12:51 ` Cyril Hrubis
2021-10-25 20:01 ` Petr Vorel
2021-10-18 15:47 ` [LTP] [PATCH 3/7] docparse: data_storage: Add integer type node Cyril Hrubis
2021-10-18 15:47 ` [LTP] [PATCH 4/7] docparse: Implement ARRAY_SIZE() Cyril Hrubis
2021-11-01 12:36 ` Richard Palethorpe
2021-11-01 13:18 ` Cyril Hrubis
2021-10-18 15:47 ` [LTP] [PATCH 5/7] docparse: Add type normalization Cyril Hrubis
2021-10-18 15:47 ` [LTP] [PATCH 6/7] docparse: Group data to 'testsuite' and 'defaults' Cyril Hrubis
2021-10-18 15:47 ` [LTP] [PATCH 7/7] docparse/Makefile: Do not abort on missing generators Cyril Hrubis
2021-10-22 11:29 ` Petr Vorel
2021-10-25 12:48 ` Cyril Hrubis
2021-10-27 9:47 ` Petr Vorel
2021-10-18 15:48 ` [LTP] [PATCH 0/7] docparse improvements Cyril Hrubis
2021-10-27 13:22 ` Richard Palethorpe
2021-10-27 13:48 ` Cyril Hrubis
2021-10-28 8:11 ` Richard Palethorpe
2021-10-29 8:54 ` Cyril Hrubis
2021-11-01 9:04 ` Richard Palethorpe
2021-11-01 9:59 ` Cyril Hrubis
2021-11-01 12:20 ` Richard Palethorpe
2021-11-01 15:10 ` Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211018154800.11013-3-chrubis@suse.cz \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).