From: Sebastien GODARD Date: Sat, 19 Dec 2020 08:03:56 +0000 (+0100) Subject: systest.c: Fix GCC warnings X-Git-Tag: v12.5.2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eeea14041430def9949b217440df46dd672fc5b8;p=sysstat systest.c: Fix GCC warnings Signed-off-by: Sebastien GODARD --- diff --git a/systest.c b/systest.c index 7277aff..acb094a 100644 --- a/systest.c +++ b/systest.c @@ -144,7 +144,7 @@ char *get_env_value(const char *c) void next_time_step(void) { int root_nr = 1; - char rootf[64], testf[64]; + char rootf[64], testf[128]; char *resolved_name; __unix_time += interval; @@ -160,8 +160,11 @@ void next_time_step(void) exit(1); } - sprintf(rootf, "%s%d", ROOTFILE, ++root_nr); - sprintf(testf, "%s/%s", TESTDIR, rootf); + snprintf(rootf, sizeof(rootf), "%s%d", ROOTFILE, ++root_nr); + rootf[sizeof(rootf) - 1] = '\0'; + snprintf(testf, sizeof(testf), "%s/%s", TESTDIR, rootf); + testf[sizeof(testf) - 1] = '\0'; + if (access(testf, F_OK) < 0) { if (errno == ENOENT) { /* No more kernel directories: Simulate a Ctrl/C */ diff --git a/tests/00100 b/tests/00050 similarity index 100% rename from tests/00100 rename to tests/00050 diff --git a/tests/00110 b/tests/00052 similarity index 100% rename from tests/00110 rename to tests/00052 diff --git a/tests/00120 b/tests/00054 similarity index 100% rename from tests/00120 rename to tests/00054 diff --git a/tests/00140 b/tests/00055 similarity index 100% rename from tests/00140 rename to tests/00055 diff --git a/tests/00150 b/tests/00057 similarity index 100% rename from tests/00150 rename to tests/00057 diff --git a/tests/01000 b/tests/00060 similarity index 100% rename from tests/01000 rename to tests/00060 diff --git a/tests/01200 b/tests/00062 similarity index 100% rename from tests/01200 rename to tests/00062 diff --git a/tests/00065 b/tests/00065 new file mode 100644 index 0000000..4885a16 --- /dev/null +++ b/tests/00065 @@ -0,0 +1,21 @@ +rm -f tests/data1.tmp + +rm -f tests/root +ln -s root6 tests/root +TZ=GMT ./sadc --unix_time=1555593609 tests/data1.tmp 1 1 >/dev/null + +rm -f tests/root +ln -s root7 tests/root +TZ=GMT ./sadc --unix_time=1555593619 tests/data1.tmp 1 1 >/dev/null + +rm -f tests/root +ln -s root1 tests/root +# LINUX RESTART +TZ=GMT ./sadc --unix_time=1555593623 tests/data1.tmp >/dev/null + +TZ=GMT ./sadc --unix_time=1555593629 tests/data1.tmp 1 1 >/dev/null + +rm -f tests/root +ln -s root2 tests/root +TZ=GMT ./sadc --unix_time=1555593639 tests/data1.tmp 1 1 >/dev/null + diff --git a/tests/00068 b/tests/00068 new file mode 100644 index 0000000..002e0ac --- /dev/null +++ b/tests/00068 @@ -0,0 +1,21 @@ +rm -f tests/data1.tmp + +rm -f tests/root +ln -s root1 tests/root +TZ=GMT ./sadc --unix_time=1555593609 tests/data1.tmp 1 1 >/dev/null + +rm -f tests/root +ln -s root2 tests/root +TZ=GMT ./sadc --unix_time=1555593619 tests/data1.tmp 1 1 >/dev/null + +# LINUX RESTART +TZ=GMT ./sadc --unix_time=1555593623 tests/data1.tmp >/dev/null + +rm -f tests/root +ln -s root6 tests/root +TZ=GMT ./sadc --unix_time=1555593629 tests/data1.tmp 1 1 >/dev/null + +rm -f tests/root +ln -s root7 tests/root +TZ=GMT ./sadc --unix_time=1555593639 tests/data1.tmp 1 1 >/dev/null + diff --git a/tests/01750 b/tests/00072 similarity index 100% rename from tests/01750 rename to tests/00072 diff --git a/tests/01800 b/tests/00074 similarity index 100% rename from tests/01800 rename to tests/00074 diff --git a/tests/00080 b/tests/00080 new file mode 100644 index 0000000..5fad1aa --- /dev/null +++ b/tests/00080 @@ -0,0 +1,17 @@ +. tests/variables +if [ "${TGLIB32}" = "yes" ]; then + rm -f tests/data32.tmp + + rm -f tests/root + ln -s root1 tests/root + TZ=GMT tests/32bits/sadc32 --unix_time=1555593609 -S XALL,-A_PWR_FAN,-A_PWR_IN,-A_PWR_TEMP,-A_PWR_FREQ tests/data32.tmp + TZ=GMT tests/32bits/sadc32 --unix_time=1555593619 -C "32 bit datafile" tests/data32.tmp + + TZ=GMT tests/32bits/sadc32 --unix_time=1555593629 -S XALL tests/data32.tmp 1 1 >/dev/null + + rm -f tests/root + ln -s root2 tests/root + TZ=GMT tests/32bits/sadc32 --unix_time=1555593639 -S XALL tests/data32.tmp 1 1 >/dev/null +else + echo Skipped +fi diff --git a/tests/00710 b/tests/00710 index 5fad1aa..df6f6ac 100644 --- a/tests/00710 +++ b/tests/00710 @@ -1,17 +1,6 @@ . tests/variables if [ "${TGLIB32}" = "yes" ]; then - rm -f tests/data32.tmp - - rm -f tests/root - ln -s root1 tests/root - TZ=GMT tests/32bits/sadc32 --unix_time=1555593609 -S XALL,-A_PWR_FAN,-A_PWR_IN,-A_PWR_TEMP,-A_PWR_FREQ tests/data32.tmp - TZ=GMT tests/32bits/sadc32 --unix_time=1555593619 -C "32 bit datafile" tests/data32.tmp - - TZ=GMT tests/32bits/sadc32 --unix_time=1555593629 -S XALL tests/data32.tmp 1 1 >/dev/null - - rm -f tests/root - ln -s root2 tests/root - TZ=GMT tests/32bits/sadc32 --unix_time=1555593639 -S XALL tests/data32.tmp 1 1 >/dev/null + LC_ALL=C TZ=GMT ./sar -C -A -f tests/data32.tmp > tests/out.sar32-A.tmp && diff -u tests/expected.sar32-A tests/out.sar32-A.tmp else echo Skipped fi diff --git a/tests/00712 b/tests/00712 deleted file mode 100644 index df6f6ac..0000000 --- a/tests/00712 +++ /dev/null @@ -1,6 +0,0 @@ -. tests/variables -if [ "${TGLIB32}" = "yes" ]; then - LC_ALL=C TZ=GMT ./sar -C -A -f tests/data32.tmp > tests/out.sar32-A.tmp && diff -u tests/expected.sar32-A tests/out.sar32-A.tmp -else - echo Skipped -fi diff --git a/tests/00720 b/tests/00740 similarity index 100% rename from tests/00720 rename to tests/00740 diff --git a/tests/00980 b/tests/00980 index 002e0ac..134b74b 100644 --- a/tests/00980 +++ b/tests/00980 @@ -1,21 +1 @@ -rm -f tests/data1.tmp - -rm -f tests/root -ln -s root1 tests/root -TZ=GMT ./sadc --unix_time=1555593609 tests/data1.tmp 1 1 >/dev/null - -rm -f tests/root -ln -s root2 tests/root -TZ=GMT ./sadc --unix_time=1555593619 tests/data1.tmp 1 1 >/dev/null - -# LINUX RESTART -TZ=GMT ./sadc --unix_time=1555593623 tests/data1.tmp >/dev/null - -rm -f tests/root -ln -s root6 tests/root -TZ=GMT ./sadc --unix_time=1555593629 tests/data1.tmp 1 1 >/dev/null - -rm -f tests/root -ln -s root7 tests/root -TZ=GMT ./sadc --unix_time=1555593639 tests/data1.tmp 1 1 >/dev/null - +LC_ALL=C TZ=GMT ./sar -f tests/data1.tmp -q ALL > tests/out2.sar-q.tmp && diff -u tests/expected2.sar-q tests/out2.sar-q.tmp diff --git a/tests/00982 b/tests/00982 deleted file mode 100644 index 134b74b..0000000 --- a/tests/00982 +++ /dev/null @@ -1 +0,0 @@ -LC_ALL=C TZ=GMT ./sar -f tests/data1.tmp -q ALL > tests/out2.sar-q.tmp && diff -u tests/expected2.sar-q tests/out2.sar-q.tmp diff --git a/tests/01010 b/tests/01010 index 4885a16..bfe681d 100644 --- a/tests/01010 +++ b/tests/01010 @@ -1,21 +1 @@ -rm -f tests/data1.tmp - -rm -f tests/root -ln -s root6 tests/root -TZ=GMT ./sadc --unix_time=1555593609 tests/data1.tmp 1 1 >/dev/null - -rm -f tests/root -ln -s root7 tests/root -TZ=GMT ./sadc --unix_time=1555593619 tests/data1.tmp 1 1 >/dev/null - -rm -f tests/root -ln -s root1 tests/root -# LINUX RESTART -TZ=GMT ./sadc --unix_time=1555593623 tests/data1.tmp >/dev/null - -TZ=GMT ./sadc --unix_time=1555593629 tests/data1.tmp 1 1 >/dev/null - -rm -f tests/root -ln -s root2 tests/root -TZ=GMT ./sadc --unix_time=1555593639 tests/data1.tmp 1 1 >/dev/null - +LC_ALL=C TZ=GMT ./sar -f tests/data1.tmp -q ALL > tests/out2.sar-qALL.tmp && diff -u tests/expected2.sar-qALL tests/out2.sar-qALL.tmp diff --git a/tests/01012 b/tests/01012 deleted file mode 100644 index bfe681d..0000000 --- a/tests/01012 +++ /dev/null @@ -1 +0,0 @@ -LC_ALL=C TZ=GMT ./sar -f tests/data1.tmp -q ALL > tests/out2.sar-qALL.tmp && diff -u tests/expected2.sar-qALL tests/out2.sar-qALL.tmp