[CRIU] [PATCH] test: thread_different_uid_gid -- More fixes
Cyrill Gorcunov
gorcunov at openvz.org
Sat Oct 14 11:00:44 MSK 2017
To make them work, missed in first place. We can
drop off mutex completely as we use task waiter.
test_daemon should be called earlier to not receive
signal later.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
Sorry for previous send, which has been built-test only.
This one does pass, on top of current criu-dev
test/zdtm/static/thread_different_uid_gid.c | 19 ++++---------------
test/zdtm/static/thread_different_uid_gid.desc | 2 +-
2 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/test/zdtm/static/thread_different_uid_gid.c b/test/zdtm/static/thread_different_uid_gid.c
index 1a6cdc976045..e992b02479a5 100644
--- a/test/zdtm/static/thread_different_uid_gid.c
+++ b/test/zdtm/static/thread_different_uid_gid.c
@@ -23,12 +23,8 @@ const char *test_author = "Vitaly Ostrosablin <vostrosablin at virtuozzo.com>";
unsigned int gid;
unsigned int uid;
-pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
task_waiter_t t;
-int done = 0;
-
void *chg_uid_gid(void *arg)
{
cap_t newcaps;
@@ -72,12 +68,7 @@ void *chg_uid_gid(void *arg)
test_msg("Child thread is waiting for main thread's signal\n");
task_waiter_complete(&t, 1);
-
- pthread_mutex_lock(&mutex);
- while (!done) {
- pthread_cond_wait(&cond, &mutex);
- }
- pthread_mutex_unlock(&mutex);
+ task_waiter_wait4(&t, 2);
test_msg("Child thread returns\n");
return NULL;
@@ -94,6 +85,8 @@ int main(int argc, char **argv)
test_init(argc, argv);
task_waiter_init(&t);
+ test_daemon();
+
if (getuid() != 0) {
fail("Test is expected to be run with root privileges\n");
exit(1);
@@ -142,7 +135,6 @@ int main(int argc, char **argv)
}
test_msg("Main thread is waiting for signal\n");
- test_daemon();
test_waitsig();
if (gid == getgid() || uid == getuid()) {
@@ -150,10 +142,7 @@ int main(int argc, char **argv)
exit(1);
}
- pthread_mutex_lock(&mutex);
- done = 1;
- pthread_cond_signal(&cond);
- pthread_mutex_unlock(&mutex);
+ task_waiter_complete(&t, 2);
pthread_join(diff_cred_thread, NULL);
test_msg("Threads joined\n");
diff --git a/test/zdtm/static/thread_different_uid_gid.desc b/test/zdtm/static/thread_different_uid_gid.desc
index 2eac7e654bf2..fa2c82d083ee 100644
--- a/test/zdtm/static/thread_different_uid_gid.desc
+++ b/test/zdtm/static/thread_different_uid_gid.desc
@@ -1 +1 @@
-{'flags': 'suid'}
+{'flavor': 'h', 'flags': 'suid'}
--
2.7.5
More information about the CRIU
mailing list