From edb9d8b55419dabf5b8ace678e5ddb5cd559972b Mon Sep 17 00:00:00 2001 From: Robert Kanter Date: Thu, 12 Jul 2018 16:38:46 -0700 Subject: [PATCH] YARN-8518. test-container-executor test_is_empty() is broken (Jim_Brennan via rkanter) (cherry picked from commit 1bc106a738a6ce4f7ed025d556bb44c1ede022e3) (cherry picked from commit 6e0db6fe1a8ce50977175567f2ba1f957e7b9c91) --- .../test/test-container-executor.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/test/test-container-executor.c b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/test/test-container-executor.c index cea41ac2773..9e85b3fbf52 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/test/test-container-executor.c +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/test/test-container-executor.c @@ -1197,19 +1197,23 @@ void test_trim_function() { free(trimmed); } +int is_empty(char *name); + void test_is_empty() { printf("\nTesting is_empty function\n"); if (is_empty("/")) { printf("FAIL: / should not be empty\n"); exit(1); } - if (is_empty("/tmp/2938rf2983hcqnw8ud/noexist")) { - printf("FAIL: /tmp/2938rf2983hcqnw8ud/noexist should not exist\n"); + char *noexist = TEST_ROOT "/noexist"; + if (is_empty(noexist)) { + printf("%s should not exist\n", noexist); exit(1); } - mkdir("/tmp/2938rf2983hcqnw8ud/emptydir", S_IRWXU); - if (!is_empty("/tmp/2938rf2983hcqnw8ud/emptydir")) { - printf("FAIL: /tmp/2938rf2983hcqnw8ud/emptydir be empty\n"); + char *emptydir = TEST_ROOT "/emptydir"; + mkdir(emptydir, S_IRWXU); + if (!is_empty(emptydir)) { + printf("FAIL: %s should be empty\n", emptydir); exit(1); } }