Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
jyf111 committed Aug 17, 2023
1 parent fbfff20 commit ff82b03
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 92 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/user_function_tracer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ jobs:
gcc test/sleep.c -o test/sleep
gcc test/mmap.c -o test/mmap
gcc test/strcpy.c -o test/strcpy
gcc test/fib.c -o test/fib
gcc test/thread.c -o test/thread
sudo build/utrace -c test/sleep
sudo build/utrace -c test/mmap
sudo build/utrace -c test/strcpy
sudo build/utrace -c test/fib
sudo build/utrace -c test/thread
68 changes: 0 additions & 68 deletions eBPF_Supermarket/User_Function_Tracer/test/args.c

This file was deleted.

26 changes: 19 additions & 7 deletions eBPF_Supermarket/User_Function_Tracer/test/fib.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// Copyright 2023 The LMP Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://github.com/linuxkerneltravel/lmp/blob/develop/LICENSE
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// author: jinyufeng2000@gmail.com
//
// 测试递归函数调用

int fib(int n) {
if (n <= 2) return 1;
return fib(n - 1) + fib(n - 2);
}

int main() {
sleep(2);
int n = 8;

return !!fib(n);
fib(9);
return 0;
}
Binary file removed eBPF_Supermarket/User_Function_Tracer/test/mmap
Binary file not shown.
18 changes: 18 additions & 0 deletions eBPF_Supermarket/User_Function_Tracer/test/mmap.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
// Copyright 2023 The LMP Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://github.com/linuxkerneltravel/lmp/blob/develop/LICENSE
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// author: jinyufeng2000@gmail.com
//
// 测试库函数调用

#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
10 changes: 0 additions & 10 deletions eBPF_Supermarket/User_Function_Tracer/test/short.c

This file was deleted.

19 changes: 18 additions & 1 deletion eBPF_Supermarket/User_Function_Tracer/test/sleep.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
#include <stdio.h>
// Copyright 2023 The LMP Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://github.com/linuxkerneltravel/lmp/blob/develop/LICENSE
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// author: jinyufeng2000@gmail.com
//
// 测试函数时延统计

#include <unistd.h>

void g() { sleep(2); }
Expand Down
18 changes: 18 additions & 0 deletions eBPF_Supermarket/User_Function_Tracer/test/strcpy.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
// Copyright 2023 The LMP Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://github.com/linuxkerneltravel/lmp/blob/develop/LICENSE
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// author: jinyufeng2000@gmail.com
//
// 测试库函数调用,涉及IFUNC符号

#include <stdlib.h>
#include <string.h>
int main() {
Expand Down
6 changes: 0 additions & 6 deletions eBPF_Supermarket/User_Function_Tracer/test/test.c

This file was deleted.

41 changes: 41 additions & 0 deletions eBPF_Supermarket/User_Function_Tracer/test/thread.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2023 The LMP Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://github.com/linuxkerneltravel/lmp/blob/develop/LICENSE
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// author: jinyufeng2000@gmail.com
//
// 测试多线程程序

#include <assert.h>
#include <pthread.h>

static void* c(void* n) { return n; }

static void* b(void* n) { return c(n); }

static void* a(void* n) { return b(n); }

int main() {
int i;
void* v;
int n = 10;
pthread_t t[4];

for (i = 0; i < 4; i++) pthread_create(&t[i], NULL, a, &n);
for (i = 0; i < 4; i++) {
pthread_join(t[i], &v);
}

assert(*(int*)v == n);
return 0;
}

0 comments on commit ff82b03

Please sign in to comment.