Commit 872ba20f authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

zdtm: Add selfexe00 test-case

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Acked-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 60f180aa
...@@ -30,6 +30,7 @@ static/pstree ...@@ -30,6 +30,7 @@ static/pstree
static/caps00 static/caps00
static/cmdlinenv00 static/cmdlinenv00
static/socket_listen static/socket_listen
static/selfexe00
" "
UTS_TEST_LIST=" UTS_TEST_LIST="
......
...@@ -32,6 +32,7 @@ TST_NOFILE = \ ...@@ -32,6 +32,7 @@ TST_NOFILE = \
pstree \ pstree \
sockets00 \ sockets00 \
ipc_namespace \ ipc_namespace \
selfexe00 \
# jobctl00 \ # jobctl00 \
TST_FILE = \ TST_FILE = \
......
/*
* A simple testee program with threads
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include "zdtmtst.h"
#define gettid() pthread_self()
const char *test_doc = "Check if /proc/self/exe points to same location after restore\n";
const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org";
int main(int argc, char *argv[])
{
char path_before[PATH_MAX];
char path_after[PATH_MAX];
test_init(argc, argv);
test_msg("%s pid %d\n", argv[0], getpid());
if (readlink("/proc/self/exe", path_before, sizeof(path_before)) < 0) {
err("Can't read selflink\n");
fail();
exit(1);
}
test_daemon();
test_waitsig();
if (readlink("/proc/self/exe", path_after, sizeof(path_after)) < 0) {
err("Can't read selflink\n");
fail();
exit(1);
}
if (!strcmp(path_before, path_after))
pass();
else
fail();
return 0;
}
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