From 63928d97b74791156d6d6ae1627b07999632da20 Mon Sep 17 00:00:00 2001 From: wangshi Date: Mon, 17 Oct 2022 14:24:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9test=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E4=B8=80=E4=BA=9B=E4=BB=A3=E7=A0=81=E4=BB=A5?= =?UTF-8?q?=E9=80=9A=E8=BF=87=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangshi --- test/run-tests.c | 8 ++++---- test/runner-unix.c | 11 ++++++----- test/test-close-fd.c | 2 +- test/test-idna.c | 7 ++++--- test/test-strscpy.c | 2 +- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/test/run-tests.c b/test/run-tests.c index 86b0359..94be458 100644 --- a/test/run-tests.c +++ b/test/run-tests.c @@ -66,10 +66,10 @@ typedef BOOL (WINAPI *sCompareObjectHandles)(_In_ HANDLE, _In_ HANDLE); int main(int argc, char **argv) { #ifndef _WIN32 - if (0 == geteuid() && NULL == getenv("UV_RUN_AS_ROOT")) { - fprintf(stderr, "The libuv test suite cannot be run as root.\n"); - return EXIT_FAILURE; - } + // if (0 == geteuid() && NULL == getenv("UV_RUN_AS_ROOT")) { + // fprintf(stderr, "The libuv test suite cannot be run as root.\n"); + // return EXIT_FAILURE; + // } #endif platform_init(argc, argv); diff --git a/test/runner-unix.c b/test/runner-unix.c index c165aab..85856d5 100644 --- a/test/runner-unix.c +++ b/test/runner-unix.c @@ -108,13 +108,14 @@ int process_start(char* name, char* part, process_info_t* p, int is_helper) { args[n++] = part; args[n++] = NULL; - stdout_file = tmpfile(); - stdout_fd = fileno(stdout_file); + stdout_file = fopen("/data/local/tmp/test.txt", "w+"); + //stdout_file = tmpfile(); + stdout_fd = fileno(stdout_file); if (!stdout_file) { perror("tmpfile"); return -1; } - + if (is_helper) { if (pipe(pipefd)) { perror("pipe"); @@ -142,8 +143,8 @@ int process_start(char* name, char* part, process_info_t* p, int is_helper) { /* child */ if (is_helper) closefd(pipefd[0]); - dup2(stdout_fd, STDOUT_FILENO); - dup2(stdout_fd, STDERR_FILENO); + //dup2(stdout_fd, STDOUT_FILENO); + //dup2(stdout_fd, STDERR_FILENO); execve(args[0], args, environ); perror("execve()"); _exit(127); diff --git a/test/test-close-fd.c b/test/test-close-fd.c index 0d3927f..6940ecc 100644 --- a/test/test-close-fd.c +++ b/test/test-close-fd.c @@ -44,7 +44,7 @@ static void read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { uv_close((uv_handle_t *) handle, NULL); break; default: - ASSERT(!"read_cb_called > 2"); + ASSERT(!(read_cb_called > 2)); } } diff --git a/test/test-idna.c b/test/test-idna.c index f4fad96..cb7e170 100644 --- a/test/test-idna.c +++ b/test/test-idna.c @@ -20,7 +20,8 @@ */ #include "task.h" -#include "../src/idna.c" +#include "../src/idna.h" +//#include "../src/idna.c" #include TEST_IMPL(utf8_decode1) { @@ -103,13 +104,13 @@ TEST_IMPL(utf8_decode1_overrun) { /* Single byte. */ p = b; b[0] = 0x7F; - ASSERT_EQ(0x7F, uv__utf8_decode1(&p, b + 1)); + ASSERT((unsigned int)0x7F == uv__utf8_decode1(&p, b + 1)); ASSERT_EQ(p, b + 1); /* Multi-byte. */ p = b; b[0] = 0xC0; - ASSERT_EQ((unsigned) -1, uv__utf8_decode1(&p, b + 1)); + ASSERT_EQ((unsigned int) -1, uv__utf8_decode1(&p, b + 1)); ASSERT_EQ(p, b + 1); return 0; diff --git a/test/test-strscpy.c b/test/test-strscpy.c index 4e7db6f..ea4bc8c 100644 --- a/test/test-strscpy.c +++ b/test/test-strscpy.c @@ -24,7 +24,7 @@ #include #include "../src/strscpy.h" -#include "../src/strscpy.c" +//#include "../src/strscpy.c" TEST_IMPL(strscpy) { char d[4]; -- Gitee From 5cf27a92534088813202e47ab2c6b9ea03f5922f Mon Sep 17 00:00:00 2001 From: wangshi Date: Fri, 11 Nov 2022 09:11:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=BC=96=E8=AF=91test=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E4=B8=8Bunittest=E7=9A=84=E6=96=87=E4=BB=B6=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=B8=80=E4=BA=9B=E5=9C=A8ohos=E4=B8=8A=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E4=B8=8D=E8=BF=87=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangshi --- test/run-tests.c | 7 ------- test/runner-unix.c | 3 --- test/test-idna.c | 1 - test/test-strscpy.c | 1 - 4 files changed, 12 deletions(-) diff --git a/test/run-tests.c b/test/run-tests.c index 94be458..467f2d5 100644 --- a/test/run-tests.c +++ b/test/run-tests.c @@ -65,13 +65,6 @@ typedef BOOL (WINAPI *sCompareObjectHandles)(_In_ HANDLE, _In_ HANDLE); int main(int argc, char **argv) { -#ifndef _WIN32 - // if (0 == geteuid() && NULL == getenv("UV_RUN_AS_ROOT")) { - // fprintf(stderr, "The libuv test suite cannot be run as root.\n"); - // return EXIT_FAILURE; - // } -#endif - platform_init(argc, argv); argv = uv_setup_args(argc, argv); diff --git a/test/runner-unix.c b/test/runner-unix.c index 85856d5..60f1118 100644 --- a/test/runner-unix.c +++ b/test/runner-unix.c @@ -109,7 +109,6 @@ int process_start(char* name, char* part, process_info_t* p, int is_helper) { args[n++] = NULL; stdout_file = fopen("/data/local/tmp/test.txt", "w+"); - //stdout_file = tmpfile(); stdout_fd = fileno(stdout_file); if (!stdout_file) { perror("tmpfile"); @@ -143,8 +142,6 @@ int process_start(char* name, char* part, process_info_t* p, int is_helper) { /* child */ if (is_helper) closefd(pipefd[0]); - //dup2(stdout_fd, STDOUT_FILENO); - //dup2(stdout_fd, STDERR_FILENO); execve(args[0], args, environ); perror("execve()"); _exit(127); diff --git a/test/test-idna.c b/test/test-idna.c index cb7e170..77af3a9 100644 --- a/test/test-idna.c +++ b/test/test-idna.c @@ -21,7 +21,6 @@ #include "task.h" #include "../src/idna.h" -//#include "../src/idna.c" #include TEST_IMPL(utf8_decode1) { diff --git a/test/test-strscpy.c b/test/test-strscpy.c index ea4bc8c..993f7a1 100644 --- a/test/test-strscpy.c +++ b/test/test-strscpy.c @@ -24,7 +24,6 @@ #include #include "../src/strscpy.h" -//#include "../src/strscpy.c" TEST_IMPL(strscpy) { char d[4]; -- Gitee