Add related code which make libcareplus can run basic demo on aarch64. Signed-off-by: Jiajie Li <lijiajie11@huawei.com>
148 lines
3.4 KiB
Diff
148 lines
3.4 KiB
Diff
From f25aa052cd31cab4c6301cca5eb8e5e5f129d5bd Mon Sep 17 00:00:00 2001
|
|
From: Pavel Boldin <pboldin@cloudlinux.com>
|
|
Date: Wed, 7 Feb 2018 23:59:39 +0200
|
|
Subject: [PATCH 15/89] add `fail to unpatch` test
|
|
|
|
Add a test sample where patch is always busy in the loop and cannot
|
|
be unapplied.
|
|
|
|
Signed-off-by: Pavel Boldin <pboldin@cloudlinux.com>
|
|
---
|
|
tests/fail_unpatch/Makefile | 4 ++++
|
|
tests/fail_unpatch/desc | 1 +
|
|
tests/fail_unpatch/fail_unpatch.c | 29 ++++++++++++++++++++++++++++
|
|
tests/fail_unpatch/fail_unpatch.diff | 11 +++++++++++
|
|
tests/run_tests.sh | 25 ++++++++++++++++++++++--
|
|
5 files changed, 68 insertions(+), 2 deletions(-)
|
|
create mode 100644 tests/fail_unpatch/Makefile
|
|
create mode 100644 tests/fail_unpatch/desc
|
|
create mode 100644 tests/fail_unpatch/fail_unpatch.c
|
|
create mode 100644 tests/fail_unpatch/fail_unpatch.diff
|
|
|
|
diff --git a/tests/fail_unpatch/Makefile b/tests/fail_unpatch/Makefile
|
|
new file mode 100644
|
|
index 0000000..d7680e9
|
|
--- /dev/null
|
|
+++ b/tests/fail_unpatch/Makefile
|
|
@@ -0,0 +1,4 @@
|
|
+
|
|
+LDLIBS:=-lpthread
|
|
+
|
|
+include ../makefile.inc
|
|
diff --git a/tests/fail_unpatch/desc b/tests/fail_unpatch/desc
|
|
new file mode 100644
|
|
index 0000000..02151c5
|
|
--- /dev/null
|
|
+++ b/tests/fail_unpatch/desc
|
|
@@ -0,0 +1 @@
|
|
+fails to unpatch the code
|
|
diff --git a/tests/fail_unpatch/fail_unpatch.c b/tests/fail_unpatch/fail_unpatch.c
|
|
new file mode 100644
|
|
index 0000000..6b5c50f
|
|
--- /dev/null
|
|
+++ b/tests/fail_unpatch/fail_unpatch.c
|
|
@@ -0,0 +1,29 @@
|
|
+#include <stdio.h>
|
|
+#include <unistd.h>
|
|
+
|
|
+void print_greetings_patched(void)
|
|
+{
|
|
+ while (1) {
|
|
+ printf("Hello. This a PATCHED version!\n");
|
|
+ sleep(1);
|
|
+ }
|
|
+}
|
|
+
|
|
+void print_greetings(void)
|
|
+{
|
|
+ printf("Hello. This is an UNPATCHED version!\n");
|
|
+}
|
|
+
|
|
+void do_work() {
|
|
+ while (1) {
|
|
+ print_greetings();
|
|
+ sleep(1);
|
|
+ }
|
|
+}
|
|
+
|
|
+int main()
|
|
+{
|
|
+ do_work();
|
|
+
|
|
+ return 0;
|
|
+}
|
|
diff --git a/tests/fail_unpatch/fail_unpatch.diff b/tests/fail_unpatch/fail_unpatch.diff
|
|
new file mode 100644
|
|
index 0000000..49738bd
|
|
--- /dev/null
|
|
+++ b/tests/fail_unpatch/fail_unpatch.diff
|
|
@@ -0,0 +1,11 @@
|
|
+--- ./fail_unpatch.c 2018-02-07 18:39:27.145493215 +0200
|
|
++++ ./fail_unpatch.c 2018-02-07 18:39:43.349482218 +0200
|
|
+@@ -11,7 +11,7 @@
|
|
+
|
|
+ void print_greetings(void)
|
|
+ {
|
|
+- printf("Hello. This is an UNPATCHED version!\n");
|
|
++ print_greetings_patched();
|
|
+ }
|
|
+
|
|
+ void do_work() {
|
|
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
|
|
index fbfb273..2bdd303 100755
|
|
--- a/tests/run_tests.sh
|
|
+++ b/tests/run_tests.sh
|
|
@@ -105,6 +105,10 @@ check_result() {
|
|
! grep_tail 'UNPATCHED'
|
|
return $?
|
|
;;
|
|
+ fail_unpatch)
|
|
+ grep_tail '\<PATCHED'
|
|
+ return $?
|
|
+ ;;
|
|
fail_*)
|
|
grep_tail 'UNPATCHED'
|
|
return $?
|
|
@@ -163,9 +167,24 @@ test_patch_files_fini() {
|
|
|
|
|
|
check_result_unpatch() {
|
|
+ local testname="$1"
|
|
local outfile="$2"
|
|
+
|
|
check_result "$@"
|
|
- test $? -ne "$(cat ${outfile}_patched)"
|
|
+ test $? -eq 0
|
|
+ local is_unpatched=$?
|
|
+
|
|
+ test "$(cat ${outfile}_patched)" -eq 1
|
|
+ local was_patched=$?
|
|
+
|
|
+ case $testname in
|
|
+ fail_unpatch)
|
|
+ test $is_unpatched -eq 0 && test $was_patched -eq 1
|
|
+ ;;
|
|
+ *)
|
|
+ test $is_unpatched -eq 1 && test $was_patched -eq 1
|
|
+ ;;
|
|
+ esac
|
|
}
|
|
|
|
test_unpatch_files_init() {
|
|
@@ -200,9 +219,11 @@ test_unpatch_files() {
|
|
|
|
check_result $testname $outfile
|
|
echo $? >${outfile}_patched
|
|
+ cat ${outfile}_patched
|
|
|
|
+ echo "============unpatching===============" >>$logfile
|
|
libcare_ctl unpatch-user -p $pid \
|
|
- >$logfile 2>&1 || :
|
|
+ >>$logfile 2>&1 || :
|
|
|
|
sleep 2
|
|
|
|
--
|
|
2.23.0
|
|
|