Commit 8adbdbb1 authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

test: add a test for mounts with external master peers

Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 9997856e
......@@ -188,6 +188,7 @@ TST_DIR = \
mntns_shared_bind02 \
mntns_root_bind \
mnt_ext_auto \
mnt_ext_master \
TST_DIR_FILE = \
chroot \
......
#include <sys/mount.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <linux/limits.h>
#include <stdio.h>
#include <stdlib.h>
#include "zdtmtst.h"
const char *test_doc = "Check that mounts with external master peers are c/r'd";
const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"
char *dirname = "mnt_ext_auto.test";
TEST_OPTION(dirname, string, "directory name", 1);
int main(int argc, char ** argv)
{
char src[PATH_MAX], dst[PATH_MAX], *root;
char *dname = "/tmp/zdtm_ext_auto.XXXXXX";
int status;
pid_t pid;
root = getenv("ZDTM_ROOT");
if (root == NULL) {
err("root");
return 1;
}
sprintf(dst, "%s/ext_mounts", getenv("ZDTM_ROOT"));
if (strcmp(getenv("ZDTM_NEWNS"), "1"))
goto test;
pid = fork();
if (pid < 0)
return 1;
if (pid == 0) {
test_ext_init(argc, argv);
mkdir(dname, 755);
sprintf(src, "%s/test", dname);
if (mount("zdtm_auto_ext_mnt", dname, "tmpfs", 0, NULL)) {
err("mount");
return 1;
}
mkdir(src, 755);
mkdir(dst, 755);
if (mount(src, dst, NULL, MS_BIND, NULL)) {
err("bind");
return 1;
}
if (mount(src, dst, NULL, MS_SLAVE, NULL)) {
err("slave");
return 1;
}
return 0;
}
wait(&status);
if (status != 0)
return 1;
test:
test_init(argc, argv);
test_daemon();
test_waitsig();
pass();
return 0;
}
--ext-mount-map auto --enable-external-masters
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment