[CRIU] [PATCH 2/2] test: crit: test core dump, v2
Ruslan Kuprieiev
kupruser at gmail.com
Tue Apr 28 13:45:50 PDT 2015
Use loop written in C with some stack of functions and -g compile
flag to be able to improve testing with gdb.
Also use readelf on produced core dump to check whether it is valid
elf file.
v2, just a bit more variables in loop.c and use sleep(), use dummy
options when launching loop.
Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
test/crit/.gitignore | 2 ++
test/crit/Makefile | 10 ++++----
test/crit/loop.c | 37 +++++++++++++++++++++++++++++
test/crit/loop.sh | 4 ----
test/crit/test.sh | 66 +++++++++++++++++++++++++++++++++++++++++-----------
5 files changed, 96 insertions(+), 23 deletions(-)
create mode 100644 test/crit/loop.c
delete mode 100755 test/crit/loop.sh
diff --git a/test/crit/.gitignore b/test/crit/.gitignore
index 9614eb6..b352a00 100644
--- a/test/crit/.gitignore
+++ b/test/crit/.gitignore
@@ -3,3 +3,5 @@
*.txt
stats-*
*.json
+loop
+core*
diff --git a/test/crit/Makefile b/test/crit/Makefile
index 028f439..89104cc 100644
--- a/test/crit/Makefile
+++ b/test/crit/Makefile
@@ -1,9 +1,9 @@
-images: clean
- setsid ./loop.sh < /dev/null &> /dev/null & \
- ../../criu dump -v4 -o dump.log -D ./ -t $${!} --shell-job
+loop:
+ gcc -g $@.c -o $@
+ chmod +x $@
-run: images
+run: clean loop
./test.sh
clean:
- rm -f *.img *.log *.txt stats-* *.json
+ rm -f *.img *.log *.txt stats-* *.json loop core.*
diff --git a/test/crit/loop.c b/test/crit/loop.c
new file mode 100644
index 0000000..6fb7b4d
--- /dev/null
+++ b/test/crit/loop.c
@@ -0,0 +1,37 @@
+#include <unistd.h>
+
+static void func_2(void)
+{
+ int var_2 = 2;
+
+ while (1) {
+ int var_while_1 = 3;
+ int var_while_2 = 4;
+ int var_sleep = 10;
+
+ sleep(var_sleep);
+ }
+}
+
+static void func_1(void)
+{
+ int var_1 = 1;
+
+ func_2();
+}
+
+static void func_0(void)
+{
+ int var_0 = 0;
+
+ func_1();
+}
+
+int main(void)
+{
+ int var_main = -1;
+
+ func_0();
+
+ return 0;
+}
diff --git a/test/crit/loop.sh b/test/crit/loop.sh
deleted file mode 100755
index 0ab34ce..0000000
--- a/test/crit/loop.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-while :; do
- sleep 1
-done
diff --git a/test/crit/test.sh b/test/crit/test.sh
index 5b0fb90..5f65a1c 100755
--- a/test/crit/test.sh
+++ b/test/crit/test.sh
@@ -1,3 +1,16 @@
+#!/bin/bash
+
+set -e
+
+echo "= Launch loop"
+setsid ./loop --fakeopt1 --fakeopt2 </dev/null &>/dev/null &
+PID=$!
+echo "= done. Loop pid $PID"
+
+echo "= Dump loop"
+../../criu dump -v4 -o dump.log -D ./ -t ${PID} --shell-job
+echo "= done"
+
images_list=$(ls -1 *.img)
function _exit {
@@ -7,20 +20,45 @@ function _exit {
fi
}
-for x in $images_list
-do
- echo "=== $x"
- if [[ $x == pages* ]]; then
- echo "skip"
- continue
- fi
+function decode_encode {
+ echo "= Test decode/encode"
+ for x in $images_list
+ do
+ echo "=== $x"
+ if [[ $x == pages* ]]; then
+ echo "skip"
+ continue
+ fi
+
+ echo " -- to json"
+ ../../crit decode -o "$x"".json" --pretty < $x || _exit $?
+ echo " -- to img"
+ ../../crit encode -i "$x"".json" > "$x"".json.img" || _exit $?
+ echo " -- cmp"
+ cmp $x "$x"".json.img" || _exit $?
- echo " -- to json"
- ../../crit decode -o "$x"".json" --pretty < $x || _exit $?
- echo " -- to img"
- ../../crit encode -i "$x"".json" > "$x"".json.img" || _exit $?
- echo " -- cmp"
- cmp $x "$x"".json.img" || _exit $?
+ echo "=== done"
+ done
+ echo "= done"
+}
+
+function core_dump {
+ echo "= Test core dump"
+ echo "=== img to core dump"
+ ../../crit core-dump -i ./ -o ./
echo "=== done"
-done
+
+ cores=$(ls -1 core.*)
+ for x in $cores
+ do
+ echo "=== try readelf $x"
+ readelf -a $x
+ echo "=== done"
+ done
+
+ echo "= done"
+}
+
+decode_encode
+core_dump
--
1.9.1
More information about the CRIU
mailing list