!15 [sync] PR-14: 修复t-socket测试用例失败
From: @openeuler-sync-bot Reviewed-by: @SuperSix173 Signed-off-by: @SuperSix173
This commit is contained in:
commit
49e8bfc4c7
@ -1,7 +1,7 @@
|
|||||||
From d5ff2e1a5f4df3b3545fde4249be6a9f69401b4d Mon Sep 17 00:00:00 2001
|
From 9ce3797bb45fc360bf0d38a0d28911b1c1ada585 Mon Sep 17 00:00:00 2001
|
||||||
From: yaowenbin <yaowenbin1@huawei.com>
|
From: yaowenbin <yaowenbin1@huawei.com>
|
||||||
Date: Tue, 1 Mar 2022 08:30:38 +0000
|
Date: Tue, 1 Mar 2022 08:30:38 +0000
|
||||||
Subject: [PATCH] add test cases
|
Subject: [PATCH 1/1] add test cases
|
||||||
|
|
||||||
The following test cases are added to test more interfaces of npth:
|
The following test cases are added to test more interfaces of npth:
|
||||||
t-condlock.c test npth condlock interfaces
|
t-condlock.c test npth condlock interfaces
|
||||||
@ -13,12 +13,12 @@ t-socket.c test npth socket interfaces
|
|||||||
Signed-off-by: yaowenbin <yaowenbin1@huawei.com>
|
Signed-off-by: yaowenbin <yaowenbin1@huawei.com>
|
||||||
---
|
---
|
||||||
tests/Makefile.am | 3 +-
|
tests/Makefile.am | 3 +-
|
||||||
tests/t-condlock.c | 106 ++++++++++++++++
|
tests/t-condlock.c | 106 +++++++++++++++
|
||||||
tests/t-fork-enhance.c | 68 +++++++++++
|
tests/t-fork-enhance.c | 68 ++++++++++
|
||||||
tests/t-rwlock.c | 196 ++++++++++++++++++++++++++++++
|
tests/t-rwlock.c | 196 ++++++++++++++++++++++++++++
|
||||||
tests/t-signal.c | 49 ++++++++
|
tests/t-signal.c | 49 +++++++
|
||||||
tests/t-socket.c | 270 +++++++++++++++++++++++++++++++++++++++++
|
tests/t-socket.c | 284 +++++++++++++++++++++++++++++++++++++++++
|
||||||
6 files changed, 691 insertions(+), 1 deletion(-)
|
6 files changed, 705 insertions(+), 1 deletion(-)
|
||||||
create mode 100644 tests/t-condlock.c
|
create mode 100644 tests/t-condlock.c
|
||||||
create mode 100644 tests/t-fork-enhance.c
|
create mode 100644 tests/t-fork-enhance.c
|
||||||
create mode 100644 tests/t-rwlock.c
|
create mode 100644 tests/t-rwlock.c
|
||||||
@ -491,10 +491,10 @@ index 0000000..45c7c97
|
|||||||
+}
|
+}
|
||||||
diff --git a/tests/t-socket.c b/tests/t-socket.c
|
diff --git a/tests/t-socket.c b/tests/t-socket.c
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..c7bfc15
|
index 0000000..94ad0bb
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/tests/t-socket.c
|
+++ b/tests/t-socket.c
|
||||||
@@ -0,0 +1,270 @@
|
@@ -0,0 +1,284 @@
|
||||||
+/* t-socket.c
|
+/* t-socket.c
|
||||||
+ *
|
+ *
|
||||||
+ * This file is free software; as a special exception the author gives
|
+ * This file is free software; as a special exception the author gives
|
||||||
@ -518,6 +518,9 @@ index 0000000..c7bfc15
|
|||||||
+#define NAME "Socket"
|
+#define NAME "Socket"
|
||||||
+#define DATA "Hello, little Baby . . ."
|
+#define DATA "Hello, little Baby . . ."
|
||||||
+
|
+
|
||||||
|
+static int server1Ready;
|
||||||
|
+static int server2Ready;
|
||||||
|
+
|
||||||
+static void *
|
+static void *
|
||||||
+thread_one (void *arg)
|
+thread_one (void *arg)
|
||||||
+{
|
+{
|
||||||
@ -536,16 +539,17 @@ index 0000000..c7bfc15
|
|||||||
+ sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
+ sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
+ if (sock < 0) {
|
+ if (sock < 0) {
|
||||||
+ perror("opening stream socket");
|
+ perror("opening stream socket");
|
||||||
+ exit(1);
|
+ goto end;
|
||||||
+ }
|
+ }
|
||||||
+ server.sun_family = AF_UNIX;
|
+ server.sun_family = AF_UNIX;
|
||||||
+ strcpy(server.sun_path, NAME);
|
+ strcpy(server.sun_path, NAME);
|
||||||
+ if (bind(sock, (struct sockaddr *) &server, sizeof(struct sockaddr_un))) {
|
+ if (bind(sock, (struct sockaddr *) &server, sizeof(struct sockaddr_un))) {
|
||||||
+ perror("binding stream socket");
|
+ perror("binding stream socket");
|
||||||
+ exit(1);
|
+ goto end;
|
||||||
+ }
|
+ }
|
||||||
+ printf("Socket has name %s\n", server.sun_path);
|
+ printf("Socket has name %s\n", server.sun_path);
|
||||||
+ listen(sock, 5);
|
+ listen(sock, 5);
|
||||||
|
+ server1Ready = 1;
|
||||||
+ msgsock = npth_accept(sock, 0, 0);
|
+ msgsock = npth_accept(sock, 0, 0);
|
||||||
+ if (msgsock == -1)
|
+ if (msgsock == -1)
|
||||||
+ perror("accept");
|
+ perror("accept");
|
||||||
@ -565,7 +569,7 @@ index 0000000..c7bfc15
|
|||||||
+ close(sock);
|
+ close(sock);
|
||||||
+ unlink(NAME);
|
+ unlink(NAME);
|
||||||
+ info_msg ("thread-one terminated");
|
+ info_msg ("thread-one terminated");
|
||||||
+
|
+end:
|
||||||
+ return (void*)4711;
|
+ return (void*)4711;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
@ -579,10 +583,14 @@ index 0000000..c7bfc15
|
|||||||
+ char buf[1024];
|
+ char buf[1024];
|
||||||
+
|
+
|
||||||
+ info_msg ("thread-two started");
|
+ info_msg ("thread-two started");
|
||||||
|
+ if (!server1Ready) {
|
||||||
|
+ info_msg ("server1 not ready");
|
||||||
|
+ goto end;
|
||||||
|
+ }
|
||||||
+ sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
+ sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
+ if (sock < 0) {
|
+ if (sock < 0) {
|
||||||
+ perror("opening stream socket");
|
+ perror("opening stream socket");
|
||||||
+ exit(1);
|
+ goto end;
|
||||||
+ }
|
+ }
|
||||||
+ server.sun_family = AF_UNIX;
|
+ server.sun_family = AF_UNIX;
|
||||||
+ strcpy(server.sun_path, NAME);
|
+ strcpy(server.sun_path, NAME);
|
||||||
@ -590,7 +598,7 @@ index 0000000..c7bfc15
|
|||||||
+ if (npth_connect(sock, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) < 0) {
|
+ if (npth_connect(sock, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) < 0) {
|
||||||
+ close(sock);
|
+ close(sock);
|
||||||
+ perror("connecting stream socket");
|
+ perror("connecting stream socket");
|
||||||
+ exit(1);
|
+ goto end;
|
||||||
+ }
|
+ }
|
||||||
+ if (npth_write(sock, DATA, sizeof(DATA)) < 0)
|
+ if (npth_write(sock, DATA, sizeof(DATA)) < 0)
|
||||||
+ perror("writing on stream socket");
|
+ perror("writing on stream socket");
|
||||||
@ -598,6 +606,7 @@ index 0000000..c7bfc15
|
|||||||
+
|
+
|
||||||
+ info_msg ("thread-two terminated");
|
+ info_msg ("thread-two terminated");
|
||||||
+
|
+
|
||||||
|
+end:
|
||||||
+ return (void*)4722;
|
+ return (void*)4722;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
@ -621,16 +630,17 @@ index 0000000..c7bfc15
|
|||||||
+ sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
+ sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
+ if (sock < 0) {
|
+ if (sock < 0) {
|
||||||
+ perror("opening stream socket");
|
+ perror("opening stream socket");
|
||||||
+ exit(1);
|
+ goto end;
|
||||||
+ }
|
+ }
|
||||||
+ server.sun_family = AF_UNIX;
|
+ server.sun_family = AF_UNIX;
|
||||||
+ strcpy(server.sun_path, NAME);
|
+ strcpy(server.sun_path, NAME);
|
||||||
+ if (bind(sock, (struct sockaddr *) &server, sizeof(struct sockaddr_un))) {
|
+ if (bind(sock, (struct sockaddr *) &server, sizeof(struct sockaddr_un))) {
|
||||||
+ perror("binding stream socket");
|
+ perror("binding stream socket");
|
||||||
+ exit(1);
|
+ goto end;
|
||||||
+ }
|
+ }
|
||||||
+ printf("Socket has name %s\n", server.sun_path);
|
+ printf("Socket has name %s\n", server.sun_path);
|
||||||
+ listen(sock, 5);
|
+ listen(sock, 5);
|
||||||
|
+ server2Ready = 1;
|
||||||
+ msgsock = npth_accept(sock, 0, 0);
|
+ msgsock = npth_accept(sock, 0, 0);
|
||||||
+ if (msgsock == -1)
|
+ if (msgsock == -1)
|
||||||
+ perror("accept");
|
+ perror("accept");
|
||||||
@ -646,7 +656,7 @@ index 0000000..c7bfc15
|
|||||||
+ close(sock);
|
+ close(sock);
|
||||||
+ unlink(NAME);
|
+ unlink(NAME);
|
||||||
+ info_msg ("thread-three terminated");
|
+ info_msg ("thread-three terminated");
|
||||||
+
|
+end:
|
||||||
+ return (void*)4711;
|
+ return (void*)4711;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
@ -668,10 +678,14 @@ index 0000000..c7bfc15
|
|||||||
+ msg.msg_iovlen = 1;
|
+ msg.msg_iovlen = 1;
|
||||||
+
|
+
|
||||||
+ info_msg ("thread-four started");
|
+ info_msg ("thread-four started");
|
||||||
|
+ if (!server2Ready) {
|
||||||
|
+ info_msg ("server2 not ready");
|
||||||
|
+ goto end;
|
||||||
|
+ }
|
||||||
+ sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
+ sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
+ if (sock < 0) {
|
+ if (sock < 0) {
|
||||||
+ perror("opening stream socket");
|
+ perror("opening stream socket");
|
||||||
+ exit(1);
|
+ goto end;
|
||||||
+ }
|
+ }
|
||||||
+ server.sun_family = AF_UNIX;
|
+ server.sun_family = AF_UNIX;
|
||||||
+ strcpy(server.sun_path, NAME);
|
+ strcpy(server.sun_path, NAME);
|
||||||
@ -679,13 +693,13 @@ index 0000000..c7bfc15
|
|||||||
+ if (npth_connect(sock, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) < 0) {
|
+ if (npth_connect(sock, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) < 0) {
|
||||||
+ close(sock);
|
+ close(sock);
|
||||||
+ perror("connecting stream socket");
|
+ perror("connecting stream socket");
|
||||||
+ exit(1);
|
+ goto end;
|
||||||
+ }
|
+ }
|
||||||
+ npth_sendmsg(sock, &msg, 0);
|
+ npth_sendmsg(sock, &msg, 0);
|
||||||
+ close(sock);
|
+ close(sock);
|
||||||
+
|
+
|
||||||
+ info_msg ("thread-four terminated");
|
+ info_msg ("thread-four terminated");
|
||||||
+
|
+end:
|
||||||
+ return (void*)4722;
|
+ return (void*)4722;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
@ -766,5 +780,5 @@ index 0000000..c7bfc15
|
|||||||
+ return 0;
|
+ return 0;
|
||||||
+}
|
+}
|
||||||
--
|
--
|
||||||
2.23.0
|
2.27.0
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
Name: npth
|
Name: npth
|
||||||
Version: 1.6
|
Version: 1.6
|
||||||
Release: 5
|
Release: 6
|
||||||
Summary: The New GNU Portable Threads library
|
Summary: The New GNU Portable Threads library
|
||||||
License: LGPLv2+
|
License: LGPLv2+
|
||||||
URL: http://git.gnupg.org/cgi-bin/gitweb.cgi?p=npth.git
|
URL: http://git.gnupg.org/cgi-bin/gitweb.cgi?p=npth.git
|
||||||
@ -62,6 +62,9 @@ make check
|
|||||||
%{_datadir}/aclocal/%{name}.m4
|
%{_datadir}/aclocal/%{name}.m4
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sat Sep 24 2022 yaowenbin1 <yaowenbin1@huawei.com> - 1.6-6
|
||||||
|
- DESC: fix t-socket test case fail
|
||||||
|
|
||||||
* Thu Mar 10 2022 EulerOSWander <314264452@qq.com> - 1.6-5
|
* Thu Mar 10 2022 EulerOSWander <314264452@qq.com> - 1.6-5
|
||||||
- DESC: posix: Add npth_poll/npth_ppoll
|
- DESC: posix: Add npth_poll/npth_ppoll
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user