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