summaryrefslogtreecommitdiffhomepage
path: root/test/hook.test.c
diff options
context:
space:
mode:
authorWillian Henrique <wsimanbrazil@yahoo.com.br>2022-02-12 23:25:04 -0300
committerMichael Smith <mikesmiffy128@gmail.com>2022-03-19 04:57:00 +0000
commite2b8151f6eca6c91b45e0d715b1533cde274eaa5 (patch)
tree2f337bcf9e2f8f2392c5869f05f4a8bc551dc11f /test/hook.test.c
parentdc317d53ccf74257c12c1d73c4265ec2a9b25d24 (diff)
Fix hook_inline() breaking after a single call
Committer note: I, mike, am a big dumb idiot. Thanks, Bill.
Diffstat (limited to 'test/hook.test.c')
-rw-r--r--test/hook.test.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/hook.test.c b/test/hook.test.c
index 831fbf6..50e07a8 100644
--- a/test/hook.test.c
+++ b/test/hook.test.c
@@ -25,6 +25,12 @@ static int (*orig_some_function)(int, int);
static int some_hook(int a, int b) {
return orig_some_function(a, b) + 5;
}
+__attribute__((noinline))
+static int other_function(int a, int b) { return a - b; }
+static int (*orig_other_function)(int, int);
+static int other_hook(int a, int b) {
+ return orig_other_function(a, b) + 5;
+}
TEST("Inline hooks should be able to wrap the original function", 0) {
orig_some_function = hook_inline(&some_function, &some_hook);
@@ -39,6 +45,16 @@ TEST("Inline hooks should be removable again", 0) {
return some_function(5, 5) == 10;
}
+TEST("Multiple functions should be able to be inline hooked at once", 0) {
+ orig_some_function = hook_inline(&some_function, &some_hook);
+ if (!orig_some_function) return false;
+
+ orig_other_function = hook_inline(&other_function, &other_hook);
+ if (!orig_other_function) return false;
+
+ return other_function(5, 5) == 5;
+}
+
#endif
// vi: sw=4 ts=4 noet tw=80 cc=80