diff options
| author | zy <[email protected]> | 2023-11-27 20:34:06 -0500 |
|---|---|---|
| committer | zy <[email protected]> | 2023-11-27 20:34:06 -0500 |
| commit | e560158cbcdc0c395276a70706510f5c6ee4d78a (patch) | |
| tree | 9dd8e88643e2b68fa67bb914763a70315b398c29 /testcase | |
| parent | 7e3b4ded0ccfe149a96aec009836bcb35293fb63 (diff) | |
reinit
Diffstat (limited to 'testcase')
| -rw-r--r-- | testcase/helloworld.c | 68 | ||||
| -rw-r--r-- | testcase/hptest.c | 2 |
2 files changed, 28 insertions, 42 deletions
diff --git a/testcase/helloworld.c b/testcase/helloworld.c index 50eaea6..55ebc73 100644 --- a/testcase/helloworld.c +++ b/testcase/helloworld.c @@ -1,51 +1,37 @@ #include "../source/uapi/monitor_user.h" #include <stdio.h> -#include <unistd.h> #include <string.h> +#include <unistd.h> #define NUM_VARS 2049 -int main() -{ - int i = 0; - int temps[NUM_VARS] = {0}; - watch_arg watch_args[NUM_VARS] = {0}; - - cancel_watch(); - - for (i = 0; i < NUM_VARS; i++) - { - temps[i] = 100; - - watch_args[i] = (watch_arg){ - .task_id = getpid(), - .ptr = &temps[i], - .name = "temp", - .length_byte = sizeof(int), - .threshold = 110 + i, - .unsigned_flag = 0, - .greater_flag = 1, - .time_ns = 2000 + (i / 33) * 5000, // on hyper-v, 1us will block all system. 2us just fine, maybe 1us is too short for hyper-v - }; - char name[20]; - snprintf(name, sizeof(name), "temp%d", i); - // 拷贝字符串 - strncpy(watch_args[i].name, name, (MAX_NAME_LEN + 1)); - - start_watch(watch_args[i]); - } +int main() { + int i = 0; + int temps[NUM_VARS] = {0}; + watch_arg watch_args[NUM_VARS] = {0}; + + cancel_watch(); + + for (i = 0; i < NUM_VARS; i++) { + temps[i] = 100; + + char name[20]; + snprintf(name, sizeof(name), "temp%d", i); + // 拷贝字符串 + strncpy(watch_args[i].name, name, (MAX_NAME_LEN + 1)); + + SWATCH_INT(name, &temps[i], (110 + i)); + } - while (temps[NUM_VARS - 1] < 205) - { - for (i = 0; i < NUM_VARS; i++) - { - temps[i]++; - } - printf("Value of variable %d: %d", i, temps[0]); - printf("\n"); - sleep(1); + while (temps[NUM_VARS - 1] < 205) { + for (i = 0; i < NUM_VARS; i++) { + temps[i]++; } + printf("Value of variable %d: %d", i, temps[0]); + printf("\n"); + sleep(1); + } - cancel_watch(); - return 0; + cancel_watch(); + return 0; } diff --git a/testcase/hptest.c b/testcase/hptest.c index 82263c1..34ce6bd 100644 --- a/testcase/hptest.c +++ b/testcase/hptest.c @@ -36,7 +36,7 @@ int main() { .name = "hptest", .length_byte = sizeof(int), .threshold = 20, - .unsigned_flag = 0, + .is_unsigned = 0, .above_threshold = 1, .time_ns = 2000, // on hyper-v, 1us will block all system. 2us just fine, maybe 1us is too short for hyper-v }; |
