591
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* This programs tests the chompCommand function used by talon.
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#include <stdlib.h>
|
|
22 |
#include <unistd.h>
|
|
23 |
#include <stdio.h>
|
|
24 |
|
|
25 |
#include <sys/types.h>
|
|
26 |
#include <sys/stat.h>
|
|
27 |
#include <fcntl.h>
|
|
28 |
|
|
29 |
|
|
30 |
#include "chomp.h"
|
|
31 |
#include "log.h"
|
|
32 |
|
|
33 |
char *positives[] = {
|
|
34 |
"c:\\apps\\talon.exe -c \"armcc -o barney.o\"",
|
|
35 |
"c:\\apps\\sbs2112-capabilites\\bin\\talon.exe -c \"armcc -o barney.o\"",
|
|
36 |
"\"c:\\apps and stuff\\talon.exe\" -c \"armcc -o barney.o\"",
|
|
37 |
"\"c:\\apps-can-cause-crxxx\\talon.exe\" -c \"armcc -o barney.o\"",
|
|
38 |
"c:\\bigspaces-\" \"\\talon.exe -c \"armcc -o barney.o\"",
|
|
39 |
"c:\\bigspaces2\" \"\\talon.exe -c \"armcc -o barney.o\"",
|
|
40 |
"c:\\apps\\talon.exe -c \"armcc -o barney.o\"",
|
|
41 |
"c:\\\"apps\"\\talon.exe -c \"armcc -o barney.o\"",
|
|
42 |
"c:\\\"ap ps\"\\talon.exe -c \"armcc -o barney.o\"",
|
|
43 |
(char *)0
|
|
44 |
};
|
|
45 |
|
|
46 |
char *negatives[] = {
|
|
47 |
"c:\\apps\\talon.exe -c\"armcc -o barney.o\"",
|
|
48 |
"c:\\apps and stuff\\talon.exe -c \"armcc -o barney.o\"",
|
|
49 |
"c:\\apps\\talon.exe -c armcc -o barney.o",
|
|
50 |
"c:\\apps\\talon.exe commandlist.tmp",
|
|
51 |
(char *)0
|
|
52 |
};
|
|
53 |
|
|
54 |
char commandstr[]="armcc -o barney.o\"";
|
|
55 |
|
|
56 |
int main(int argc, char *argv[])
|
|
57 |
{
|
|
58 |
int i;
|
|
59 |
int errors = 0;
|
|
60 |
/* loglevel = LOGDEBUG; /* useful to leave this here */
|
|
61 |
|
|
62 |
for (i=0; positives[i] != (char *)0 ; i++)
|
|
63 |
{
|
|
64 |
char * c = chompCommand(positives[i]);
|
|
65 |
if (!c)
|
|
66 |
{
|
|
67 |
fprintf(stdout,"error: test failed with NULL on: %s\n", positives[i]);
|
|
68 |
errors++;
|
|
69 |
continue;
|
|
70 |
}
|
|
71 |
|
|
72 |
if (strcmp(commandstr, c) != 0)
|
|
73 |
{
|
|
74 |
fprintf(stdout,"error: test failed with %s on: %s\n", c,positives[i]);
|
|
75 |
errors++;
|
|
76 |
continue;
|
|
77 |
}
|
|
78 |
fprintf(stdout,"ok: %s\n", positives[i]);
|
|
79 |
}
|
|
80 |
|
|
81 |
for (i=0; negatives[i] != (char *)0 ; i++)
|
|
82 |
{
|
|
83 |
char * c = chompCommand(negatives[i]);
|
|
84 |
if (c)
|
|
85 |
{
|
|
86 |
fprintf(stdout,"error: negatice test failed with %s on: %s\n", c, negatives[i]);
|
|
87 |
errors++;
|
|
88 |
continue;
|
|
89 |
}
|
|
90 |
fprintf(stdout,"ok: negative: %s\n", negatives[i]);
|
|
91 |
}
|
|
92 |
|
|
93 |
|
|
94 |
fprintf(stdout,"TOTAL errors: %d\n", errors);
|
|
95 |
return errors;
|
|
96 |
}
|