-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: generate checkpoint image files for tests
Previously, tests were run against a stats-dump file available in the test directory. Now that we require other checkpoint files to test the functionality added through CRIT, a proper checkpoint is generated with CRIU and used. Signed-off-by: Prajwal S N <[email protected]>
- Loading branch information
Showing
12 changed files
with
164 additions
and
48 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 |
---|---|---|
|
@@ -2,3 +2,5 @@ checkpointctl | |
checkpointctl.coverage | ||
.coverage | ||
junit.xml | ||
test/loop/loop | ||
test/test-imgs |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
CRIU ?= criu | ||
|
||
all: test clean | ||
|
||
test: test-imgs | ||
@echo "Running BATS tests..." | ||
bats checkpointctl.bats | ||
|
||
test-junit: test-imgs | ||
@echo "Running BATS tests with JUnit results..." | ||
bats -F junit checkpointctl.bats > junit.xml | ||
|
||
test-imgs: loop/loop | ||
$(eval PID := $(shell loop/loop)) | ||
mkdir -p $@ | ||
$(CRIU) dump -v4 -o dump.log -D $@ -t $(PID) | ||
|
||
loop/loop: | ||
$(MAKE) -C loop | ||
|
||
clean: | ||
@echo "Cleaning up test files..." | ||
@rm -rf test-imgs loop/loop | ||
|
||
.PHONY: all test test-junit clean |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,9 @@ | ||
CC ?= gcc | ||
|
||
loop: loop.c | ||
$(CC) $^ -o $@ | ||
|
||
clean: | ||
@rm -f loop | ||
|
||
.PHONY: clean |
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,63 @@ | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <fcntl.h> | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
|
||
int main(void) | ||
{ | ||
pid_t pid; | ||
pid_t sid; | ||
int res = EXIT_FAILURE; | ||
int start_pipe[2]; | ||
|
||
if (pipe(start_pipe)) { | ||
perror("pipe failed!"); | ||
goto out; | ||
} | ||
|
||
pid = fork(); | ||
if (pid < 0) { | ||
perror("fork failed!"); | ||
goto out; | ||
} | ||
|
||
if (pid == 0) { | ||
close(start_pipe[0]); | ||
|
||
sid = setsid(); | ||
if (sid < 0) { | ||
perror("setsid failed!"); | ||
res = EXIT_FAILURE; | ||
write(start_pipe[1], &res, sizeof(res)); | ||
close(start_pipe[1]); | ||
exit(1); | ||
} | ||
|
||
// Create a file descriptor for "crit x ./ fds" test | ||
open("/dev/null", O_RDONLY); | ||
|
||
chdir("/"); | ||
close(STDIN_FILENO); | ||
close(STDOUT_FILENO); | ||
close(STDERR_FILENO); | ||
|
||
res = EXIT_SUCCESS; | ||
write(start_pipe[1], &res, sizeof(res)); | ||
close(start_pipe[1]); | ||
|
||
while (1) { | ||
sleep(1); | ||
} | ||
} | ||
|
||
close(start_pipe[1]); | ||
read(start_pipe[0], &res, sizeof(res)); | ||
close(start_pipe[0]); | ||
|
||
out: | ||
if (res == EXIT_SUCCESS) | ||
printf("%d\n", pid); | ||
return res; | ||
} |
Binary file not shown.