| 181 | */ |
| 182 | |
| 183 | void execnt_unit_test() |
| 184 | { |
| 185 | #if !defined( NDEBUG ) |
| 186 | /* vc6 preprocessor is broken, so assert with these strings gets confused. |
| 187 | * Use a table instead. |
| 188 | */ |
| 189 | { |
| 190 | typedef struct test { const char * command; int32_t result; } test; |
| 191 | test tests[] = { |
| 192 | { "", 0 }, |
| 193 | { " ", 0 }, |
| 194 | { "x", 1 }, |
| 195 | { "\nx", 1 }, |
| 196 | { "x\n", 1 }, |
| 197 | { "\nx\n", 1 }, |
| 198 | { "\nx \n", 2 }, |
| 199 | { "\nx \n ", 2 }, |
| 200 | { " \n\t\t\v\r\r\n \t x \v \t\t\r\n\n\n \n\n\v\t", 8 }, |
| 201 | { "x\ny", -1 }, |
| 202 | { "x\n\n y", -1 }, |
| 203 | { "echo x > foo.bar", -1 }, |
| 204 | { "echo x < foo.bar", -1 }, |
| 205 | { "echo x | foo.bar", -1 }, |
| 206 | { "echo x \">\" foo.bar", 18 }, |
| 207 | { "echo x '<' foo.bar", 18 }, |
| 208 | { "echo x \"|\" foo.bar", 18 }, |
| 209 | { "echo x \\\">\\\" foo.bar", -1 }, |
| 210 | { "echo x \\\"<\\\" foo.bar", -1 }, |
| 211 | { "echo x \\\"|\\\" foo.bar", -1 }, |
| 212 | { "\"echo x > foo.bar\"", 18 }, |
| 213 | { "echo x \"'\"<' foo.bar", -1 }, |
| 214 | { "echo x \\\\\"<\\\\\" foo.bar", 22 }, |
| 215 | { "echo x \\x\\\"<\\\\\" foo.bar", -1 }, |
| 216 | { 0 } }; |
| 217 | test const * t; |
| 218 | for ( t = tests; t->command; ++t ) |
| 219 | assert( raw_command_length( t->command ) == t->result ); |
| 220 | } |
| 221 | |
| 222 | { |
| 223 | int32_t const length = maxline() + 9; |
| 224 | char * const cmd = (char *)BJAM_MALLOC_ATOMIC( size_t(length) + 1 ); |
| 225 | memset( cmd, 'x', size_t(length) ); |
| 226 | cmd[ length ] = 0; |
| 227 | assert( raw_command_length( cmd ) == length ); |
| 228 | BJAM_FREE( cmd ); |
| 229 | } |
| 230 | #endif |
| 231 | } |
| 232 | |
| 233 | /* |
| 234 | * exec_init() - global initialization |
no test coverage detected