tests: add a quick plugin test
authorEddie Hung <eddie@fpgeh.com>
Thu, 9 Apr 2020 16:45:20 +0000 (09:45 -0700)
committerEddie Hung <eddie@fpgeh.com>
Thu, 9 Apr 2020 16:45:20 +0000 (09:45 -0700)
tests/various/.gitignore
tests/various/plugin.cc [new file with mode: 0644]
tests/various/plugin.sh [new file with mode: 0644]

index 4b286fd61a610346ea87c681ba3c9e318a31fbcd..12d4e504856abff908f3bd666e201eda47e0664d 100644 (file)
@@ -3,3 +3,4 @@
 /write_gzip.v
 /write_gzip.v.gz
 /run-test.mk
+/plugin.so
diff --git a/tests/various/plugin.cc b/tests/various/plugin.cc
new file mode 100644 (file)
index 0000000..be305fb
--- /dev/null
@@ -0,0 +1,15 @@
+#include "kernel/rtlil.h"
+
+YOSYS_NAMESPACE_BEGIN
+
+struct TestPass : public Pass {
+       TestPass() : Pass("test", "test") { }
+       void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE
+       {
+               size_t argidx = 1;
+               extra_args(args, argidx, design);
+               log("Plugin test passed!\n");
+       }
+} TestPass;
+
+YOSYS_NAMESPACE_END
diff --git a/tests/various/plugin.sh b/tests/various/plugin.sh
new file mode 100644 (file)
index 0000000..d6d4aee
--- /dev/null
@@ -0,0 +1,6 @@
+set -e
+rm -f plugin.so
+CXXFLAGS=$(../../yosys-config --cxxflags)
+CXXFLAGS=${CXXFLAGS// -I\/usr\/local\/share\/yosys\/include/ -I..\/..\/share\/include}
+../../yosys-config --exec --cxx ${CXXFLAGS} --ldflags -shared -o plugin.so plugin.cc
+../../yosys -m ./plugin.so -p "test" | grep -q "Plugin test passed!"