aboutsummaryrefslogtreecommitdiff
path: root/plugin/test
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2024-09-30 18:37:16 -0700
committer3gg <3gg@shellblade.net>2024-09-30 18:37:16 -0700
commitd6113123b8666c32d4b718f089806a968aabe2d2 (patch)
tree52c8434e23d65207259a8fd28385c2beec1f9357 /plugin/test
parentda9a6a75acac8c8597d807757bbd9e60f39c31de (diff)
Add plugin test.
Diffstat (limited to 'plugin/test')
-rw-r--r--plugin/test/hello_plugin.c3
-rw-r--r--plugin/test/plugin_test.c31
2 files changed, 34 insertions, 0 deletions
diff --git a/plugin/test/hello_plugin.c b/plugin/test/hello_plugin.c
new file mode 100644
index 0000000..1ab290f
--- /dev/null
+++ b/plugin/test/hello_plugin.c
@@ -0,0 +1,3 @@
1#include <stdio.h>
2
3void SayHello() { printf("Hello!\n"); }
diff --git a/plugin/test/plugin_test.c b/plugin/test/plugin_test.c
new file mode 100644
index 0000000..d31bab6
--- /dev/null
+++ b/plugin/test/plugin_test.c
@@ -0,0 +1,31 @@
1#include "plugin.h"
2
3#include "test.h"
4
5#include <stdio.h>
6
7typedef void (*SayHelloFunc)(void);
8
9TEST_CASE(test_hello_plugin) {
10 PluginEngine* eng =
11 new_plugin_engine(&(PluginEngineDesc){.plugins_dir = "."});
12 TEST_TRUE(eng != 0);
13
14 Plugin* plugin = load_plugin(eng, "hello_plugin");
15 TEST_TRUE(plugin != 0);
16
17 plugin_call(plugin, SayHelloFunc, "SayHello");
18
19 printf("Now modify the plugin, build it, and press enter");
20 fflush(stdout);
21 getchar();
22
23 plugin_engine_update(eng);
24
25 plugin_call(plugin, SayHelloFunc, "SayHello");
26
27 delete_plugin_engine(&eng);
28 TEST_TRUE(eng == 0);
29}
30
31int main() { return 0; }