forked from checkpoint-restore/criu
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds 6 tests: 1. The last byte of the file is altered after dump and before restore, causing restore to fail (checksum-full) 2. checksum, checksum-parameter = 10485800 (First 10485800 bytes are checksummed) 3. checksum-period, checksum-parameter = 10485800 (Every 10485800th byte is checksummed) 4. checksum, checksum-parameter = 10485700 (First 10485700 bytes are checksummed) 5. checksum-period, checksum-parameter = 10485700 (Every 10485700th byte is checksummed) 6. The last byte of a file of size 10485800 bytes is altered after dump and before restore, causing restore to fail checksum, checksum-parameter = 10485800 (First 10485800 bytes are checksummed) Signed-off-by: Ajay Bharadwaj <ajayrbharadwaj@gmail.com>
- Loading branch information
1 parent
ee9ded1
commit 2ef7543
Showing
19 changed files
with
467 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <errno.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <sys/mman.h> | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <fcntl.h> | ||
|
||
#include "zdtmtst.h" | ||
|
||
const char *test_doc = "File validation test for checksum (Should fail during restore, uses checksum-full)"; | ||
const char *test_author = "Ajay Bharadwaj <ajayrbharadwaj@gmail.com>"; | ||
|
||
char *filename; | ||
TEST_OPTION(filename, string, "file name", 1); | ||
|
||
#define BUF_SIZE 1024 | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int fd; | ||
uint8_t buf[BUF_SIZE]; | ||
uint32_t crc; | ||
|
||
test_init(argc, argv); | ||
|
||
fd = open(filename, O_RDWR | O_CREAT, 0666); | ||
if (fd < 0) { | ||
pr_perror("Can't open %s", filename); | ||
return 1; | ||
} | ||
|
||
crc = ~0; | ||
datagen(buf, BUF_SIZE, &crc); | ||
if (write_data(fd, buf, BUF_SIZE)) { | ||
pr_perror("write() failed"); | ||
return 1; | ||
} | ||
|
||
test_daemon(); | ||
test_waitsig(); | ||
|
||
if (close(fd) < 0) { | ||
pr_perror("Can't close %s", filename); | ||
return 1; | ||
} | ||
|
||
fail("Restore passed even though file was altered\n"); | ||
return 0; | ||
} |
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 @@ | ||
{'opts': '--file-validation checksum-full', 'flags': 'crfail-restore'} |
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,16 @@ | ||
#!/bin/bash | ||
|
||
[ "$1" == "--clean" -o "$1" == "--pre-restore" ] || exit 0 | ||
|
||
filename="${0%.*}.test" | ||
|
||
if [ "$1" == "--pre-restore" ] | ||
then | ||
set -e -- $(ls -l $filename) | ||
pos=$(( $5 - 1 )) | ||
data=$(od -j "$pos" -t u1 -A n "$9") | ||
invdata=$(printf '%02x' $(( data ^ 0xff ))) | ||
printf "\\x${invdata}" | dd of="$9" obs="$pos" seek=1 | ||
else | ||
rm $filename | ||
fi |
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,74 @@ | ||
#include <errno.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <sys/mman.h> | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <fcntl.h> | ||
|
||
#include "zdtmtst.h" | ||
|
||
const char *test_doc = "File validation test for checksum (checksum-first) with checksum parameter greater than CHSKM_CHUNK_SIZE (10MB)"; | ||
const char *test_author = "Ajay Bharadwaj <ajayrbharadwaj@gmail.com>"; | ||
|
||
char *filename; | ||
TEST_OPTION(filename, string, "file name", 1); | ||
|
||
#define BUF_SIZE 104857600 | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int fd; | ||
void *buf; | ||
uint32_t crc; | ||
|
||
test_init(argc, argv); | ||
|
||
fd = open(filename, O_RDWR | O_CREAT, 0666); | ||
if (fd < 0) { | ||
pr_perror("Can't open %s", filename); | ||
return 1; | ||
} | ||
|
||
buf = mmap(NULL, BUF_SIZE, PROT_WRITE | PROT_READ, | ||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | ||
if (buf == MAP_FAILED) { | ||
pr_perror("mmap() failed"); | ||
return 1; | ||
} | ||
|
||
crc = ~0; | ||
datagen(buf, BUF_SIZE, &crc); | ||
if (write_data(fd, buf, BUF_SIZE)) { | ||
pr_perror("write() failed"); | ||
return 1; | ||
} | ||
|
||
test_daemon(); | ||
test_waitsig(); | ||
|
||
if (lseek(fd, 0, SEEK_SET) < 0) | ||
{ | ||
pr_perror("lseek() failed"); | ||
return -1; | ||
} | ||
|
||
if (read_data(fd, buf, BUF_SIZE)) { | ||
pr_perror("read() failed"); | ||
return 1; | ||
} | ||
|
||
crc = ~0; | ||
if (datachk(buf, BUF_SIZE, &crc)) { | ||
fail("Data in file has been changed\n"); | ||
return 1; | ||
} | ||
|
||
if (close(fd) < 0) { | ||
pr_perror("Can't close %s", filename); | ||
return 1; | ||
} | ||
|
||
pass(); | ||
return 0; | ||
} |
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 @@ | ||
{'opts': '--file-validation checksum --checksum-parameter 10485800'} |
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,5 @@ | ||
#!/bin/bash | ||
|
||
[ "$1" == "--clean" ] || exit 0 | ||
|
||
rm "${0%.*}.test" |
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,74 @@ | ||
#include <errno.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <sys/mman.h> | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <fcntl.h> | ||
|
||
#include "zdtmtst.h" | ||
|
||
const char *test_doc = "File validation test for checksum (checksum-period) with checksum parameter greater than CHSKM_CHUNK_SIZE (10MB)"; | ||
const char *test_author = "Ajay Bharadwaj <ajayrbharadwaj@gmail.com>"; | ||
|
||
char *filename; | ||
TEST_OPTION(filename, string, "file name", 1); | ||
|
||
#define BUF_SIZE 104857600 | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int fd; | ||
void *buf; | ||
uint32_t crc; | ||
|
||
test_init(argc, argv); | ||
|
||
fd = open(filename, O_RDWR | O_CREAT, 0666); | ||
if (fd < 0) { | ||
pr_perror("Can't open %s", filename); | ||
return 1; | ||
} | ||
|
||
buf = mmap(NULL, BUF_SIZE, PROT_WRITE | PROT_READ, | ||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | ||
if (buf == MAP_FAILED) { | ||
pr_perror("mmap() failed"); | ||
return 1; | ||
} | ||
|
||
crc = ~0; | ||
datagen(buf, BUF_SIZE, &crc); | ||
if (write_data(fd, buf, BUF_SIZE)) { | ||
pr_perror("write() failed"); | ||
return 1; | ||
} | ||
|
||
test_daemon(); | ||
test_waitsig(); | ||
|
||
if (lseek(fd, 0, SEEK_SET) < 0) | ||
{ | ||
pr_perror("lseek() failed"); | ||
return -1; | ||
} | ||
|
||
if (read_data(fd, buf, BUF_SIZE)) { | ||
pr_perror("read() failed"); | ||
return 1; | ||
} | ||
|
||
crc = ~0; | ||
if (datachk(buf, BUF_SIZE, &crc)) { | ||
fail("Data in file has been changed\n"); | ||
return 1; | ||
} | ||
|
||
if (close(fd) < 0) { | ||
pr_perror("Can't close %s", filename); | ||
return 1; | ||
} | ||
|
||
pass(); | ||
return 0; | ||
} |
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 @@ | ||
{'opts': '--file-validation checksum-period --checksum-parameter 10485800'} |
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,5 @@ | ||
#!/bin/bash | ||
|
||
[ "$1" == "--clean" ] || exit 0 | ||
|
||
rm "${0%.*}.test" |
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,74 @@ | ||
#include <errno.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <sys/mman.h> | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <fcntl.h> | ||
|
||
#include "zdtmtst.h" | ||
|
||
const char *test_doc = "File validation test for checksum (checksum-first) with checksum parameter less than CHSKM_CHUNK_SIZE (10MB)"; | ||
const char *test_author = "Ajay Bharadwaj <ajayrbharadwaj@gmail.com>"; | ||
|
||
char *filename; | ||
TEST_OPTION(filename, string, "file name", 1); | ||
|
||
#define BUF_SIZE 104857600 | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int fd; | ||
void *buf; | ||
uint32_t crc; | ||
|
||
test_init(argc, argv); | ||
|
||
fd = open(filename, O_RDWR | O_CREAT, 0666); | ||
if (fd < 0) { | ||
pr_perror("Can't open %s", filename); | ||
return 1; | ||
} | ||
|
||
buf = mmap(NULL, BUF_SIZE, PROT_WRITE | PROT_READ, | ||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | ||
if (buf == MAP_FAILED) { | ||
pr_perror("mmap() failed"); | ||
return 1; | ||
} | ||
|
||
crc = ~0; | ||
datagen(buf, BUF_SIZE, &crc); | ||
if (write_data(fd, buf, BUF_SIZE)) { | ||
pr_perror("write() failed"); | ||
return 1; | ||
} | ||
|
||
test_daemon(); | ||
test_waitsig(); | ||
|
||
if (lseek(fd, 0, SEEK_SET) < 0) | ||
{ | ||
pr_perror("lseek() failed"); | ||
return -1; | ||
} | ||
|
||
if (read_data(fd, buf, BUF_SIZE)) { | ||
pr_perror("read() failed"); | ||
return 1; | ||
} | ||
|
||
crc = ~0; | ||
if (datachk(buf, BUF_SIZE, &crc)) { | ||
fail("Data in file has been changed\n"); | ||
return 1; | ||
} | ||
|
||
if (close(fd) < 0) { | ||
pr_perror("Can't close %s", filename); | ||
return 1; | ||
} | ||
|
||
pass(); | ||
return 0; | ||
} |
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 @@ | ||
{'opts': '--file-validation checksum --checksum-parameter 10485700'} |
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,5 @@ | ||
#!/bin/bash | ||
|
||
[ "$1" == "--clean" ] || exit 0 | ||
|
||
rm "${0%.*}.test" |
Oops, something went wrong.