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