[compiler-rt] r299858 - [msan] Reorder unittests for future parametrization.
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 10 10:22:07 PDT 2017
Author: vitalybuka
Date: Mon Apr 10 12:22:06 2017
New Revision: 299858
URL: http://llvm.org/viewvc/llvm-project?rev=299858&view=rev
Log:
[msan] Reorder unittests for future parametrization.
Reviewers: eugenis
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D31892
Modified:
compiler-rt/trunk/lib/msan/tests/msan_test.cc
Modified: compiler-rt/trunk/lib/msan/tests/msan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/msan_test.cc?rev=299858&r1=299857&r2=299858&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Mon Apr 10 12:22:06 2017
@@ -927,74 +927,6 @@ TEST(MemorySanitizer, accept) {
close(listen_socket);
}
-TEST(MemorySanitizer, getaddrinfo) {
- struct addrinfo *ai;
- struct addrinfo hints;
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_INET;
- int res = getaddrinfo("localhost", NULL, &hints, &ai);
- ASSERT_EQ(0, res);
- EXPECT_NOT_POISONED(*ai);
- ASSERT_EQ(sizeof(sockaddr_in), ai->ai_addrlen);
- EXPECT_NOT_POISONED(*(sockaddr_in*)ai->ai_addr);
-}
-
-TEST(MemorySanitizer, getnameinfo) {
- struct sockaddr_in sai;
- memset(&sai, 0, sizeof(sai));
- sai.sin_family = AF_INET;
- sai.sin_port = 80;
- sai.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
- char host[500];
- char serv[500];
- int res = getnameinfo((struct sockaddr *)&sai, sizeof(sai), host,
- sizeof(host), serv, sizeof(serv), 0);
- ASSERT_EQ(0, res);
- EXPECT_NOT_POISONED(host[0]);
- EXPECT_POISONED(host[sizeof(host) - 1]);
-
- ASSERT_NE(0U, strlen(host));
- EXPECT_NOT_POISONED(serv[0]);
- EXPECT_POISONED(serv[sizeof(serv) - 1]);
- ASSERT_NE(0U, strlen(serv));
-}
-
-#define EXPECT_HOSTENT_NOT_POISONED(he) \
- do { \
- EXPECT_NOT_POISONED(*(he)); \
- ASSERT_NE((void *) 0, (he)->h_name); \
- ASSERT_NE((void *) 0, (he)->h_aliases); \
- ASSERT_NE((void *) 0, (he)->h_addr_list); \
- EXPECT_NOT_POISONED(strlen((he)->h_name)); \
- char **p = (he)->h_aliases; \
- while (*p) { \
- EXPECT_NOT_POISONED(strlen(*p)); \
- ++p; \
- } \
- char **q = (he)->h_addr_list; \
- while (*q) { \
- EXPECT_NOT_POISONED(*q[0]); \
- ++q; \
- } \
- EXPECT_NOT_POISONED(*q); \
- } while (0)
-
-TEST(MemorySanitizer, gethostent) {
- struct hostent *he = gethostent();
- ASSERT_NE((void *)NULL, he);
- EXPECT_HOSTENT_NOT_POISONED(he);
-}
-
-#ifndef MSAN_TEST_DISABLE_GETHOSTBYNAME
-
-TEST(MemorySanitizer, gethostbyname) {
- struct hostent *he = gethostbyname("localhost");
- ASSERT_NE((void *)NULL, he);
- EXPECT_HOSTENT_NOT_POISONED(he);
-}
-
-#endif // MSAN_TEST_DISABLE_GETHOSTBYNAME
-
TEST(MemorySanitizer, recvmsg) {
int server_socket = socket(AF_INET, SOCK_DGRAM, 0);
ASSERT_LT(0, server_socket);
@@ -1065,6 +997,74 @@ TEST(MemorySanitizer, recvmsg) {
close(client_socket);
}
+#define EXPECT_HOSTENT_NOT_POISONED(he) \
+ do { \
+ EXPECT_NOT_POISONED(*(he)); \
+ ASSERT_NE((void *)0, (he)->h_name); \
+ ASSERT_NE((void *)0, (he)->h_aliases); \
+ ASSERT_NE((void *)0, (he)->h_addr_list); \
+ EXPECT_NOT_POISONED(strlen((he)->h_name)); \
+ char **p = (he)->h_aliases; \
+ while (*p) { \
+ EXPECT_NOT_POISONED(strlen(*p)); \
+ ++p; \
+ } \
+ char **q = (he)->h_addr_list; \
+ while (*q) { \
+ EXPECT_NOT_POISONED(*q[0]); \
+ ++q; \
+ } \
+ EXPECT_NOT_POISONED(*q); \
+ } while (0)
+
+TEST(MemorySanitizer, gethostent) {
+ struct hostent *he = gethostent();
+ ASSERT_NE((void *)NULL, he);
+ EXPECT_HOSTENT_NOT_POISONED(he);
+}
+
+#ifndef MSAN_TEST_DISABLE_GETHOSTBYNAME
+
+TEST(MemorySanitizer, gethostbyname) {
+ struct hostent *he = gethostbyname("localhost");
+ ASSERT_NE((void *)NULL, he);
+ EXPECT_HOSTENT_NOT_POISONED(he);
+}
+
+#endif // MSAN_TEST_DISABLE_GETHOSTBYNAME
+
+TEST(MemorySanitizer, getaddrinfo) {
+ struct addrinfo *ai;
+ struct addrinfo hints;
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET;
+ int res = getaddrinfo("localhost", NULL, &hints, &ai);
+ ASSERT_EQ(0, res);
+ EXPECT_NOT_POISONED(*ai);
+ ASSERT_EQ(sizeof(sockaddr_in), ai->ai_addrlen);
+ EXPECT_NOT_POISONED(*(sockaddr_in*)ai->ai_addr);
+}
+
+TEST(MemorySanitizer, getnameinfo) {
+ struct sockaddr_in sai;
+ memset(&sai, 0, sizeof(sai));
+ sai.sin_family = AF_INET;
+ sai.sin_port = 80;
+ sai.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ char host[500];
+ char serv[500];
+ int res = getnameinfo((struct sockaddr *)&sai, sizeof(sai), host,
+ sizeof(host), serv, sizeof(serv), 0);
+ ASSERT_EQ(0, res);
+ EXPECT_NOT_POISONED(host[0]);
+ EXPECT_POISONED(host[sizeof(host) - 1]);
+
+ ASSERT_NE(0U, strlen(host));
+ EXPECT_NOT_POISONED(serv[0]);
+ EXPECT_POISONED(serv[sizeof(serv) - 1]);
+ ASSERT_NE(0U, strlen(serv));
+}
+
TEST(MemorySanitizer, gethostbyname2) {
struct hostent *he = gethostbyname2("localhost", AF_INET);
ASSERT_NE((void *)NULL, he);
More information about the llvm-commits
mailing list