Просмотр исходного кода

Unit test: Error message if "localhost" cannot be resolved

This seems to be a special case of container test environments.
bel2125 3 лет назад
Родитель
Сommit
9660ca555d
2 измененных файлов с 9 добавлено и 5 удалено
  1. 3 3
      examples/embedded_c/embedded_c.c
  2. 6 2
      unittest/private.c

+ 3 - 3
examples/embedded_c/embedded_c.c

@@ -4,9 +4,9 @@
  * License http://opensource.org/licenses/mit-license.php MIT License
  */
 
-/* Note: This example ommits some error checking and input validation for a better 
- * clarity/readability of the code. Example codes undergo less quality management 
- * than the main source files of this project. */
+/* Note: This example ommits some error checking and input validation for a
+ * better clarity/readability of the code. Example codes undergo less quality
+ * management than the main source files of this project. */
 
 #ifdef NO_SSL
 #define TEST_WITHOUT_SSL

+ 6 - 2
unittest/private.c

@@ -698,9 +698,13 @@ START_TEST(test_parse_port_string)
 	vec.ptr = "localhost:123";
 	vec.len = strlen(vec.ptr);
 	ret = parse_port_string(&vec, &so, &ip_family);
-	ck_assert_int_eq(ret, 1);
+	if (ret != 1) {
+		ck_abort_msg("IP of localhost seems to be unknown on this system (%i)",
+		             (int)ret);
+	}
 	if ((ip_family != 4) && (ip_family != 6)) {
-		ck_abort_msg("IP family must be 4 or 6 but is %i", (int)ip_family);
+		ck_abort_msg("IP family for localhost must be 4 or 6 but is %i",
+		             (int)ip_family);
 	}
 	ck_assert_int_eq((int)htons(so.lsa.sin.sin_port), (int)123);
 }