jorton 2002/12/06 05:50:50
Modified: test testsockopt.c
Log:
Rework set_debug test to work on platforms which allow setting SO_DEBUG
as a user (Solaris, HP-UX, ...); just test for set/get consistency
of this option.
Revision Changes Path
1.14 +12 -21 apr/test/testsockopt.c
Index: testsockopt.c
===================================================================
RCS file: /home/cvs/apr/test/testsockopt.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- testsockopt.c 3 Dec 2002 06:32:13 -0000 1.13
+++ testsockopt.c 6 Dec 2002 13:50:50 -0000 1.14
@@ -84,28 +84,19 @@
static void set_debug(CuTest *tc)
{
- apr_status_t rv;
+ apr_status_t rv1, rv2;
apr_int32_t ck;
-
- rv = apr_socket_opt_set(sock, APR_SO_DEBUG, 1);
- /* Grrrr, this is annoying, but APR_SO_DEBUG is only valid if the program
- * is running as root. Rather than add all the logic to determine who
- * the program is running as, I have just added a simple compile time
- * check.
- */
-#if RUN_AS_ROOT
- CuAssertIntEquals(tc, APR_SUCCESS, rv);
-#else
- CuAssertIntEquals(tc, 1, APR_STATUS_IS_EACCES(rv));
-#endif
-
- rv = apr_socket_opt_get(sock, APR_SO_DEBUG, &ck);
- CuAssertIntEquals(tc, APR_SUCCESS, rv);
-#if RUN_AS_ROOT
- CuAssertIntEquals(tc, 1, ck);
-#else
- CuAssertIntEquals(tc, 0, ck);
-#endif
+
+ /* On some platforms APR_SO_DEBUG can only be set as root; just test
+ * for get/set consistency of this option. */
+ rv1 = apr_socket_opt_set(sock, APR_SO_DEBUG, 1);
+ rv2 = apr_socket_opt_get(sock, APR_SO_DEBUG, &ck);
+ CuAssertSuccess(tc, "get SO_DEBUG option", rv2);
+ if (APR_STATUS_IS_SUCCESS(rv1)) {
+ CuAssertIntEquals(tc, 1, ck);
+ } else {
+ CuAssertIntEquals(tc, 0, ck);
+ }
}
static void remove_keepalive(CuTest *tc)