-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test] update test and add a test script
- Loading branch information
Showing
9 changed files
with
72 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [email protected] | ||
// | ||
// Test performance | ||
|
||
#include <cstdio> | ||
#include <chrono> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
// | ||
// author: [email protected] | ||
// | ||
// 测试递归函数调用 | ||
// Test recursive function calls | ||
|
||
int fib(int n) { | ||
if (n <= 2) return 1; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
// | ||
// author: [email protected] | ||
// | ||
// 测试库函数调用 | ||
// Test library calls | ||
|
||
#include <fcntl.h> | ||
#include <stdio.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [email protected] | ||
# | ||
# Test script | ||
|
||
#!/bin/bash | ||
|
||
set -e | ||
|
||
for file in test/*; do | ||
if [[ $file == *.c ]]; then | ||
gcc $file | ||
echo "test $file using gcc" | ||
sudo build/utrace -c a.out | ||
echo "test $file using clang" | ||
clang $file | ||
sudo build/utrace -c a.out | ||
elif [[ $file == *.cpp ]]; then | ||
g++ $file | ||
echo "test $file using g++" | ||
sudo build/utrace -c a.out --output=/dev/null | ||
echo "test $file using clang++" | ||
clang++ $file | ||
sudo build/utrace -c a.out --output=/dev/null | ||
fi | ||
done | ||
|
||
rm a.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
// | ||
// author: [email protected] | ||
// | ||
// 测试函数时延统计 | ||
// Test function duration measurement | ||
|
||
#include <unistd.h> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,11 @@ | |
// | ||
// author: [email protected] | ||
// | ||
// 测试库函数调用,涉及IFUNC符号 | ||
// Test library calls, involving GNU ifunc calls | ||
|
||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
int main() { | ||
char *s = "Hello!"; | ||
char *t = malloc(15 * sizeof(char)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,20 +14,20 @@ | |
// | ||
// author: [email protected] | ||
// | ||
// 测试多线程程序 | ||
// Test multi-threaded program | ||
|
||
#include <assert.h> | ||
#include <pthread.h> | ||
|
||
static void* c(void* n) { return n; } | ||
static void *c(void *n) { return n; } | ||
|
||
static void* b(void* n) { return c(n); } | ||
static void *b(void *n) { return c(n); } | ||
|
||
static void* a(void* n) { return b(n); } | ||
static void *a(void *n) { return b(n); } | ||
|
||
int main() { | ||
int i; | ||
void* v; | ||
void *v; | ||
int n = 10; | ||
pthread_t t[4]; | ||
|
||
|
@@ -36,6 +36,6 @@ int main() { | |
pthread_join(t[i], &v); | ||
} | ||
|
||
assert(*(int*)v == n); | ||
assert(*(int *)v == n); | ||
return 0; | ||
} |