criu/test/zdtm/static/deleted_dev.c
Dmitry Safonov a007f53bc1 arm/test: fix printing formats in tests
Fixes:

cow01.c: In function 'parent_check':
../lib/zdtmtst.h:120:11: error: format '%lx' expects argument of type 'long unsigned int', but argument 7 has type 'uint64_t {aka long long unsigned int}' [-Werror=format=]
  test_msg("FAIL: %s:%d: " format " (errno = %d (%s))\n", \
           ^
cow01.c:287:5: note: in expansion of macro 'fail'
     fail("%s[%#x]: %p is not COW-ed (pagemap of "
     ^~~~
In file included from inotify_system.c:14:0:
inotify_system.c: In function 'read_set':
../lib/zdtmtst.h:117:11: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'unsigned int' [-Werror=form
at=]
  test_msg("ERR: %s:%d: " format " (errno = %d (%s))\n", \
           ^
inotify_system.c:299:3: note: in expansion of macro 'pr_perror'
   pr_perror("read(%d, buf, %lu) Failed, errno=%d",
   ^~~~~~~~~
deleted_dev.c:53:36: error: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type '__dev_t {aka long long unsigned
 int}' [-Werror=format=]
   test_msg("mode %x want %x, dev %lx want %lx\n",
                                    ^
deleted_dev.c:53:45: error: format '%lx' expects argument of type 'long unsigned int', but argument 5 has type 'dev_t {aka long long unsigned i
nt}' [-Werror=format=]
   test_msg("mode %x want %x, dev %lx want %lx\n",
                                             ^
../lib/zdtmtst.h:117:11: error: format '%lx' expects argument of type 'long unsigned int', but argument 5 has type 'off64_t {aka long long int
' [-Werror=format=]
  test_msg("ERR: %s:%d: " format " (errno = %d (%s))\n", \
           ^

Nothing really interesting, but printings with right format specifier.

Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2016-09-06 19:31:21 +03:00

75 lines
1.5 KiB
C

#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "zdtmtst.h"
const char *test_doc = "Check that we can migrate with a device special file "
"open and unlinked before migration";
const char *test_author = "Roman Kagan <rkagan@parallels.com>";
char *filename;
TEST_OPTION(filename, string, "file name", 1);
int main(int argc, char **argv)
{
int fd;
struct stat st;
/* /dev/null params - sure to exist in a VPS */
mode_t mode = S_IFCHR | 0700;
dev_t dev = makedev(1, 3);
test_init(argc, argv);
if (mknod(filename, mode, dev)) {
pr_perror("can't make device file \"%s\"", filename);
exit(1);
}
fd = open(filename, O_RDWR);
if (fd < 0) {
pr_perror("can't open %s", filename);
goto out;
}
if (unlink(filename) < 0) {
pr_perror("can't unlink %s", filename);
goto out;
}
test_daemon();
test_waitsig();
if (fstat(fd, &st) < 0) {
fail("can't stat %s: %m", filename);
goto out;
}
if (st.st_mode != mode || st.st_rdev != dev) {
fail("%s is no longer the device file we had", filename);
test_msg("mode %x want %x, dev %llx want %llx\n",
st.st_mode, mode,
(long long unsigned)st.st_rdev,
(long long unsigned)dev);
goto out;
}
if (close(fd) < 0) {
fail("can't close %s: %m", filename);
goto out;
}
if (unlink(filename) != -1 || errno != ENOENT) {
fail("file %s should have been deleted before migration: unlink: %m\n", filename);
goto out;
}
pass();
out:
close(fd);
unlink(filename);
return 0;
}