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