From d7087248c6179d9abf77c647f1d0d2e4e5b2dc5b Mon Sep 17 00:00:00 2001 From: Lyon Date: Sun, 23 Jul 2023 19:01:35 +0800 Subject: [PATCH] fix socket_GET test case --- .../pikascript/pikascript-lib/socket/_socket.c | 9 +++++---- port/linux/push-core.sh | 4 ++++ port/linux/test/module-test.cpp | 10 ++++++++-- port/linux/test/python/socket/socket_GET.py | 3 +-- port/linux/test/test_common.h | 17 +++++++++++++++++ port/linux/version.sh | 1 - src/PikaVersion.h | 8 ++++---- 7 files changed, 39 insertions(+), 13 deletions(-) diff --git a/port/linux/package/pikascript/pikascript-lib/socket/_socket.c b/port/linux/package/pikascript/pikascript-lib/socket/_socket.c index ef5081d97..31b8ec11c 100644 --- a/port/linux/package/pikascript/pikascript-lib/socket/_socket.c +++ b/port/linux/package/pikascript/pikascript-lib/socket/_socket.c @@ -165,16 +165,17 @@ char* _socket__gethostname(PikaObj* self) { return obj_cacheStr(self, hostname); } -char* _socket__gethostbyname(PikaObj *self, char* host){ - struct hostent *host_entry; - char *ip = NULL; +char* _socket__gethostbyname(PikaObj* self, char* host) { + struct hostent* host_entry; + char* ip = NULL; host_entry = pika_platform_gethostbyname(host); if (host_entry == NULL) { obj_setErrorCode(self, PIKA_RES_ERR_RUNTIME_ERROR); __platform_printf("gethostbyname error\n"); return NULL; } - ip = pika_platform_inet_ntoa(*((struct in_addr *)host_entry->h_addr_list[0])); + ip = + pika_platform_inet_ntoa(*((struct in_addr*)host_entry->h_addr_list[0])); return obj_cacheStr(self, ip); } diff --git a/port/linux/push-core.sh b/port/linux/push-core.sh index 0bff2f1b7..619cac97f 100644 --- a/port/linux/push-core.sh +++ b/port/linux/push-core.sh @@ -16,6 +16,10 @@ sh std_push.sh PikaStdData sh std_push.sh PikaDebug sh std_push.sh PikaStdTask sh std_push.sh builtins + +sh version.sh +python3 format.py + echo "$FLAG_OK Push \033[32mpikascript-core\033[0m to ../../src successfully!" echo "$FLAG_OK Push \033[32mPikaSdLib\033[0m to ../../package/PikaStdLib successfully!" echo "$FLAG_NOTE Now, you can run 'git commit -a' to commit changes." diff --git a/port/linux/test/module-test.cpp b/port/linux/test/module-test.cpp index f6cab92b5..0375ce990 100644 --- a/port/linux/test/module-test.cpp +++ b/port/linux/test/module-test.cpp @@ -291,8 +291,14 @@ TEST(socket, json_issue) { } #endif -TEST_RUN_SINGLE_FILE_PASS(socket, socket_GET, "test/python/socket/socket_GET.py") -TEST_RUN_SINGLE_FILE_PASS(socket, socket_DNS, "test/python/socket/socket_DNS.py") +TEST_RUN_SINGLE_FILE_ASSERT(socket, + socket_GET, + "test/python/socket/socket_GET.py", + obj_getBool(pikaMain, "res") == pika_true) + +TEST_RUN_SINGLE_FILE_PASS(socket, + socket_DNS, + "test/python/socket/socket_DNS.py") #endif diff --git a/port/linux/test/python/socket/socket_GET.py b/port/linux/test/python/socket/socket_GET.py index 422ea909b..0bbf18725 100644 --- a/port/linux/test/python/socket/socket_GET.py +++ b/port/linux/test/python/socket/socket_GET.py @@ -27,5 +27,4 @@ while True: s.close() -assert 'HTTP/1.1 200 OK' in response -print('PASS') +res = 'HTTP/1.1 200 OK' in response diff --git a/port/linux/test/test_common.h b/port/linux/test/test_common.h index 1b6515000..3f6c59cae 100644 --- a/port/linux/test/test_common.h +++ b/port/linux/test/test_common.h @@ -59,6 +59,23 @@ extern char log_buff[LOG_BUFF_MAX][LOG_SIZE]; EXPECT_EQ(pikaMemNow(), 0); \ } +#define TEST_RUN_SINGLE_FILE_ASSERT(_test_suite_, _test_name_, _file_name_, \ + __expt__) \ + TEST(_test_suite_, _test_name_) { \ + g_PikaMemInfo.heapUsedMax = 0; \ + PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain); \ + extern unsigned char pikaModules_py_a[]; \ + obj_linkLibrary(pikaMain, pikaModules_py_a); \ + /* run */ \ + __platform_printf("BEGIN\r\n"); \ + pikaVM_runSingleFile(pikaMain, _file_name_); \ + /* assert */ \ + EXPECT_TRUE((__expt__)); \ + /* deinit */ \ + obj_deinit(pikaMain); \ + EXPECT_EQ(pikaMemNow(), 0); \ + } + #define TEST_RUN_SINGLE_FILE_EXCEPT_OUTPUT(_test_suite_, _test_name_, \ _file_name_, _except_output_) \ TEST(_test_suite_, _test_name_) { \ diff --git a/port/linux/version.sh b/port/linux/version.sh index f8ccebd63..ace106793 100644 --- a/port/linux/version.sh +++ b/port/linux/version.sh @@ -1,3 +1,2 @@ python3 version.py mv PikaVersion.h package/pikascript/pikascript-core/ -sh push-core.sh diff --git a/src/PikaVersion.h b/src/PikaVersion.h index 986475d9d..92b8652ab 100644 --- a/src/PikaVersion.h +++ b/src/PikaVersion.h @@ -1,5 +1,5 @@ -#define PIKA_VERSION_MAJOR 1 -#define PIKA_VERSION_MINOR 12 -#define PIKA_VERSION_MICRO 4 +#define PIKA_VERSION_MAJOR 1 +#define PIKA_VERSION_MINOR 12 +#define PIKA_VERSION_MICRO 4 -#define PIKA_EDIT_TIME "2023/07/20 13:04:16" +#define PIKA_EDIT_TIME "2023/07/23 19:00:47"