Closed Bug 233321 Opened 21 years ago Closed 21 years ago

utf8.c doesn't build as a standalone test program.

Categories

(NSS :: Libraries, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: wtc, Assigned: wtc)

Details

Attachments

(4 files)

lib/util/utf8.c is supposed to be able to be built as a standalone test program. However, if you do "gmake tests" in lib/util on Unix, you get a linker error: spd04:/u/wtc/nss-tip/mozilla/security/nss/lib/util 113% gmake tests cc -g -KPIC -DSVR4 -DSYSV -D__svr4 -D__svr4__ -DSOLARIS -D_REENTRANT -DSOLARIS2_ 8 -D_SVID_GETTOD -xarch=v8 -xs -DXP_UNIX -DDEBUG -UNDEBUG -DDEBUG_wtc -I/usr/dt/ include -I/usr/openwin/include -I../../../../dist/SunOS5.8_DBG.OBJ/include -I.. /../../../dist/public/nss -I../../../../dist/private/nss -I../../../../dist/publ ic/dbm -o SunOS5.8_DBG.OBJ/test_utf8 -DTEST_UTF8 utf8.c -lthread -lnsl -lsocket -lposix4 -ldl -lc Undefined first referenced symbol in file PR_Assert utf8.o ld: fatal: Symbol referencing errors. No output written to SunOS5.8_DBG.OBJ/test _utf8 Now I realize why most of the PORT_Assert statements in utf8.c are protected with #ifndef TEST_UTF8. There are three ways to fix this. 1. Protect all of the PORT_Assert statements in utf8.c with #ifndef TEST_UTF8. 2. Use libc's assert if TEST_UTF8 is defined. Use PORT_Assert if TEST_UTF8 is not defined. 3. Modify lib/util/Makefile to link with -lnspr4 when we compile utf8.c as a standalone test program. Then we can remove the #ifndef TEST_UTF8 protection for PORT_Assert in utf8.c. I will attach patches that implement solutions 1 and 2.
Attached patch Solution 1Splinter Review
Attached patch Solution 2Splinter Review
Attached patch Solution 3Splinter Review
OK, here is Solution 3, for completeness. The reason I don't like Solution 3 is that we'd need to set LD_LIBRARY_PATH in order to run the test program (it needs to know where to find libnspr4.so at run time). Nelson, let me know which solution you like.
Comment on attachment 140775 [details] [diff] [review] Solution 1 Wither solution 2 or 3 is fine with me. Does <assert.h> exist on all mozilla platforms?
Attachment #140775 - Flags: review-
Attached patch Solution 2aSplinter Review
This is a variant of Solution 2. Instead of defining a new macro UTF8_Assert, I just redefine PORT_Assert to be assert if TEST_UTF8 is defined. I also fixed two other problems. 1. The 'tests' makefile target has a special meaning in coreconf. So I changed the makefile target to 'test'. 2. The iso88591 test doesn't work on x86 because the byte_order function swapps e->c to network byte order, so we need to swap it back to host byte order before taking the least significant byte.
Comment on attachment 140800 [details] [diff] [review] Solution 2a <assert.h> is a Standard C library header. The utf8 test uses three other Standard C library headers and a Unix header (<netinet/in.h>), so using <assert.h> should not make it less portable.
Attachment #140800 - Flags: review?(MisterSSL)
Comment on attachment 140800 [details] [diff] [review] Solution 2a I know tht at least one platform to which we have ported NSS in the past, a handheld OS, does not include a complete standard C library. Nonetheless, I approve. the test program needn't run on every platform, I guess.
Attachment #140800 - Flags: review?(MisterSSL) → review+
I checked in Solution 2a. Checking in Makefile; /cvsroot/mozilla/security/nss/lib/util/Makefile,v <-- Makefile new revision: 1.5; previous revision: 1.4 done Checking in utf8.c; /cvsroot/mozilla/security/nss/lib/util/utf8.c,v <-- utf8.c new revision: 1.10; previous revision: 1.9 done Nelson, I can check in Solution 3 instead if you prefer that. Or I can define PORT_Assert as #ifdef TEST_UTF8 #undef PORT_Assert #define PORT_Assert ((void) 0) #endif to avoid the dependency on <assert.h>. Let me know.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Target Milestone: --- → 3.10
Setting priorities on unprioritized bugs resolved fixed for NSS 3.10. I marked this one P3 because AFAIK we didn't change the NSS builds to actually build the utf8 test program, and don't run it in the nightly QA tests, so it hasn't really become part of the release.
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: