int ret = EXIT_FAILURE;
unsigned long filesize;
unsigned long filename_length;
+ int debug_output = 0;
+
+ if (getenv("DEBUG_SKIPCPIO")) {
+ if (strcmp(getenv("DEBUG_SKIPCPIO"), "1") == 0) {
+ debug_output = 1;
+ }
+ }
if (argc != 2) {
fprintf(stderr, "Usage: %s <file>\n", argv[0]);
/* check, if this is a cpio archive */
if (memcmp(buf.cpio.h.c_magic, CPIO_MAGIC, CPIO_MAGIC_LEN)) {
+ if (debug_output) {
+ fprintf(stderr, "No CPIO header found.\n");
+ }
goto cat_rest;
}
pr_err("fseek\n");
goto end;
}
+ if (debug_output) {
+ fprintf(stderr, "CPIO data and any trailing zeros end at position %ld.\n", (pos-1));
+ }
break;
}
11
12
EOF
+
+ DEBUG_SKIPCPIO=1 "$skipcpio_path"/skipcpio "$CPIO_TESTDIR/skipcpio_simple.cpio" \
+ > /dev/null 2> "$CPIO_TESTDIR/debug.log"
+ if [ ! -s "$CPIO_TESTDIR/debug.log" ]; then
+ echo "Debug log file is missing or empty."
+ return 1
+ fi
+ if ! grep -q "CPIO data and any trailing zeros end at position" "$CPIO_TESTDIR/debug.log"; then
+ echo "Expected debug message not found in log."
+ return 1
+ fi
+
+ truncate -s 1K "$CPIO_TESTDIR/empty.img"
+ DEBUG_SKIPCPIO=1 "$skipcpio_path"/skipcpio "$CPIO_TESTDIR/empty.img" > /dev/null \
+ 2> "$CPIO_TESTDIR/debug.log"
+ if [ ! -s "$CPIO_TESTDIR/debug.log" ]; then
+ echo "Debug log file is missing or empty."
+ return 1
+ fi
+ if ! grep -q "No CPIO header found." "$CPIO_TESTDIR/debug.log"; then
+ echo "Expected debug message not found in log."
+ return 1
+ fi
}
test_run() {