Include the name of the program that is trying to trucate itself
to error messages to distinguish between output for different
test cases (e.g. test_lower and test_upper in overlay/013).
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
+#include <libgen.h>
int main(int argc, char *argv[])
{
+ const char *progname = basename(argv[0]);
int ret;
ret = truncate(argv[0], 4096);
if (ret != -1) {
- fprintf(stderr, "truncate(argv[0]) should have failed\n");
+ fprintf(stderr, "truncate(%s) should have failed\n",
+ progname);
return 1;
}
if (errno != ETXTBSY) {
- perror("truncate(argv[0])");
+ perror(progname);
return 1;
}