Nmap Development mailing list archives
Re: [Patch] nsock/tests/tests_main.c
From: Gisle Vanem <gvanem () broadpark no>
Date: Wed, 07 Aug 2013 12:50:51 +0200
"Henri Doreau" <henri.doreau () gmail com> wrote:
I've committed the socket_strerror() part with a little change (r31677). Can you elaborate on why ANSI codes should be avoided? I wouldn't put them everywhere but they're something quite common for such tests.
On machines where you have an ANSI-driver in the console, yes. The Windows console doesn't have that. Running this here now produces these codes verbatim on the console (not colour changes): g:\MingW32\src\inet\nmap\nsock\tests> tests_main.exe nsock pool user data [←[1m←[32mOK←[0m] test timer operations [←[1m←[32mOK←[0m] set standard log levels [←[1m←[32mOK←[0m] check error log levels [←[1m←[32mOK←[0m] simple tcp connection Socket troubles: No error Assertion failed: sd >= 0, file engine_select.c, line 353 The assert() is also a non-portable issue with WinPcap; it doesn't have a selectable pcap structure or something. Back to the colours on Windows. tests_main.c could have some macros like: #ifdef WIN32 #define BOLDGREEN (FOREGROUND_GREEN | FOREGROUND_INTENSITY) /* default WinCon state */ static CONSOLE_SCREEN_BUFFER_INFO csbi; static void init_console (void) { ... } #define PRINT_OK() \ SetConsoleTextAttribute (stdout_hnd, (csbi.wAttributes & 0xf0) | BOLDGREEN); \ printf ("OK\n"); \ SetConsoleTextAttribute (stdout_hnd, csbi.wAttributes) #else #define PRINT_OK() printf(TEST_OK "\n"); #endif And use PRINT_OK() instead of printf(TEST_OK "\n"). Similar for TEST_FAILED. I could make a patch if there's an interest. --gv _______________________________________________ Sent through the dev mailing list http://nmap.org/mailman/listinfo/dev Archived at http://seclists.org/nmap-dev/
Current thread:
- [Patch] nsock/tests/tests_main.c Gisle Vanem (Aug 06)
- Re: [Patch] nsock/tests/tests_main.c Henri Doreau (Aug 06)
- Re: [Patch] nsock/tests/tests_main.c Gisle Vanem (Aug 07)
- Re: [Patch] nsock/tests/tests_main.c Gisle Vanem (Aug 07)
- Re: [Patch] nsock/tests/tests_main.c Henri Doreau (Aug 10)
- Re: [Patch] nsock/tests/tests_main.c Gisle Vanem (Aug 10)
- Re: [Patch] nsock/tests/tests_main.c Henri Doreau (Aug 11)
- Re: [Patch] nsock/tests/tests_main.c Gisle Vanem (Aug 12)
- Re: [Patch] nsock/tests/tests_main.c Henri Doreau (Aug 13)
- Re: [Patch] nsock/tests/tests_main.c Gisle Vanem (Aug 07)
- Re: [Patch] nsock/tests/tests_main.c Henri Doreau (Aug 06)
- Re: [Patch] nsock/tests/tests_main.c Gisle Vanem (Aug 07)
- Re: [Patch] nsock/tests/tests_main.c Henri Doreau (Aug 10)