author | timothy.murphy@nokia.com |
Mon, 15 Mar 2010 15:52:03 +0000 | |
branch | fix |
changeset 359 | 6173843d1ce4 |
parent 256 | ac7e607c7d30 |
permissions | -rw-r--r-- |
3 | 1 |
/* |
256
ac7e607c7d30
SF Bug 2000 - tidy up copyright dates
timothy.murphy@nokia.com
parents:
252
diff
changeset
|
2 |
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 | 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: |
|
252
6846d05399b6
SF Bug 2000 - test code for commandline parsing.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents:
3
diff
changeset
|
15 |
* This programs tests the process execution functions in talon. |
6846d05399b6
SF Bug 2000 - test code for commandline parsing.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents:
3
diff
changeset
|
16 |
* it executes it's first argument with the following arguments |
6846d05399b6
SF Bug 2000 - test code for commandline parsing.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents:
3
diff
changeset
|
17 |
* as parameters to it. Output is buffered and finally printed. |
6846d05399b6
SF Bug 2000 - test code for commandline parsing.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents:
3
diff
changeset
|
18 |
* Should be run from within valgrind if possible to detect memory |
6846d05399b6
SF Bug 2000 - test code for commandline parsing.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents:
3
diff
changeset
|
19 |
* corruption errors. |
3 | 20 |
*/ |
21 |
||
22 |
||
23 |
||
24 |
||
25 |
#include <stdlib.h> |
|
26 |
#include <unistd.h> |
|
27 |
#include <stdio.h> |
|
28 |
||
29 |
#include <sys/types.h> |
|
30 |
#include <sys/stat.h> |
|
31 |
#include <fcntl.h> |
|
32 |
||
33 |
||
34 |
#include "process.h" |
|
35 |
||
36 |
int main(int argc, char *argv[]) |
|
37 |
{ |
|
38 |
char *shell = getenv("TALON_SHELL"); |
|
39 |
char **args = malloc((argc+2)*sizeof(char *)); |
|
40 |
int i; |
|
41 |
proc *p; |
|
42 |
||
43 |
for (i=1; i < argc; i++) |
|
44 |
{ |
|
45 |
args[i] = argv[i]; |
|
46 |
printf("arg: %s\n", args[i]); |
|
47 |
} |
|
48 |
args[argc] = NULL; |
|
49 |
||
50 |
if (! shell) |
|
51 |
{ |
|
52 |
fprintf(stderr, "error: %s", "TALONSHELL not set in environment\n"); |
|
53 |
return 1; |
|
54 |
} |
|
55 |
||
56 |
args[0] = shell; |
|
57 |
p = process_run(shell, args, 4000); |
|
58 |
||
59 |
if (p) |
|
60 |
{ |
|
61 |
||
62 |
buffer_prepend(p->output, "<recipe>\n<!CDATA<[[\n", 20); |
|
63 |
buffer_append(p->output, "\n]]></recipe>\n", 13); |
|
64 |
||
65 |
unsigned int iterator = 0; |
|
66 |
byteblock *bb; |
|
67 |
while ((bb = buffer_getbytes(p->output, &iterator))) |
|
68 |
{ |
|
69 |
write(STDOUT_FILENO, &bb->byte0, bb->fill); |
|
70 |
} |
|
71 |
||
72 |
process_free(&p); |
|
73 |
} else { |
|
74 |
fprintf(stderr, "error: %s", "failed to run process\n"); |
|
75 |
return 1; |
|
76 |
} |
|
77 |
||
78 |
free(args); |
|
79 |
return 0; |
|
80 |
} |