summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/dummy.c51
-rw-r--r--test/dummy_test.h26
-rw-r--r--test/main.c44
-rw-r--r--test/meson.build9
-rw-r--r--test/test.c36
-rw-r--r--test/test.h44
6 files changed, 210 insertions, 0 deletions
diff --git a/test/dummy.c b/test/dummy.c
new file mode 100644
index 0000000..1ee1b6d
--- /dev/null
+++ b/test/dummy.c
@@ -0,0 +1,51 @@
+/*
+ * Usurpation – "conformance" tests
+ *
+ * Copyright (C) 2017-2019 Gediminas Jakutis
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stddef.h>
+#include "test.h"
+
+static int dummy_placeholder_test(void);
+
+int dummy_test(char *testname)
+{
+ static const struct test tests[] = {
+ {"placeholder", dummy_placeholder_test}
+ };
+ size_t i;
+
+ for (i = 0; i < arrlen(tests); ++i) {
+ if (!strcmp(testname, tests[i].name)) {
+ return tests[i].testfunc();
+ }
+ }
+
+ return EXIT_FAILURE;
+}
+
+static int dummy_placeholder_test(void)
+{
+ int ret;
+
+ /* basically a NOOP */
+ ret = ok(0, "");
+
+ return ret;
+}
+
diff --git a/test/dummy_test.h b/test/dummy_test.h
new file mode 100644
index 0000000..cb11705
--- /dev/null
+++ b/test/dummy_test.h
@@ -0,0 +1,26 @@
+/*
+ * Usurpation – "conformance" tests
+ *
+ * Copyright (C) 2017-2019 Gediminas Jakutis
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef USURPATION_DUMMY_TEST_INCLUDED
+#define USURPATION_DUMMY_TEST_INCLUDED
+
+int dummy_test(char *testname);
+
+#endif /* USURPATION_DUMMY_TEST_INCLUDED */
diff --git a/test/main.c b/test/main.c
new file mode 100644
index 0000000..840b1e7
--- /dev/null
+++ b/test/main.c
@@ -0,0 +1,44 @@
+/*
+ * Usurpation – "conformance" tests
+ *
+ * Copyright (C) 2015-2019 Gediminas Jakutis
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stddef.h>
+#include "test.h"
+#include "dummy_test.h"
+
+int main(int argc, char **argv)
+{
+ static const struct section sections[] = {
+ {"dummy", dummy_test}
+ };
+
+ size_t i;
+
+ if (argc != 3) {
+ return EXIT_FAILURE;
+ }
+
+ for (i = 0; i < arrlen(sections); ++i) {
+ if (!strcmp(argv[1], sections[i].name)) {
+ return sections[i].testfunc(argv[2]);
+ }
+ }
+
+ return EXIT_FAILURE;
+}
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..a3fbf0b
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,9 @@
+test_filenames = [
+ 'main.c',
+ 'test.c',
+ 'dummy.c'
+ ]
+
+test_sources = files(test_filenames)
+test_e = executable('test executable', test_sources, include_directories : inc)
+test('dummy', test_e, args : ['dummy', 'placeholder'])
diff --git a/test/test.c b/test/test.c
new file mode 100644
index 0000000..fb5a650
--- /dev/null
+++ b/test/test.c
@@ -0,0 +1,36 @@
+/*
+ * Usurpation – "conformance" tests
+ *
+ * Copyright (C) 2015-2017 Gediminas Jakutis
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "test.h"
+
+int ok(const unsigned int test, const char *format, ...)
+{
+ static int ret;
+ va_list args;
+
+ if (test) {
+ ++ret;
+ va_start(args, format);
+ vfprintf(stderr, format, args);
+ fputc('\n', stderr);
+ }
+
+ return ret;
+}
diff --git a/test/test.h b/test/test.h
new file mode 100644
index 0000000..810f630
--- /dev/null
+++ b/test/test.h
@@ -0,0 +1,44 @@
+/*
+ * Usurpation – "conformance" tests
+ *
+ * Copyright (C) 2015-2017 Gediminas Jakutis
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef USURPATION_TEST_INCLUDED
+#define USURPATION_TEST_INCLUDED
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+
+/* TODO: move to a shared util header */
+#define arrlen(a) (sizeof(a)/sizeof(a[0]))
+
+struct section {
+ char *name;
+ int (*testfunc)(char*);
+};
+
+struct test {
+ char *name;
+ int (*testfunc)(void);
+};
+
+int ok(const unsigned int test, const char *format, ...);
+
+#endif /* USURPATION_TEST_INCLUDED */