Johannes Sixt | 2b541bf | 2010-01-10 14:11:22 +0100 | [diff] [blame] | 1 | /* |
| 2 | * test-run-command.c: test run command API. |
| 3 | * |
| 4 | * (C) 2009 Ilari Liusvaara <ilari.liusvaara@elisanet.fi> |
| 5 | * |
| 6 | * This code is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | |
| 11 | #include "git-compat-util.h" |
| 12 | #include "run-command.h" |
| 13 | #include <string.h> |
| 14 | #include <errno.h> |
| 15 | |
| 16 | int main(int argc, char **argv) |
| 17 | { |
| 18 | struct child_process proc; |
| 19 | |
| 20 | memset(&proc, 0, sizeof(proc)); |
| 21 | |
| 22 | if (argc < 3) |
| 23 | return 1; |
| 24 | proc.argv = (const char **)argv+2; |
| 25 | |
| 26 | if (!strcmp(argv[1], "start-command-ENOENT")) { |
| 27 | if (start_command(&proc) < 0 && errno == ENOENT) |
| 28 | return 0; |
| 29 | fprintf(stderr, "FAIL %s\n", argv[1]); |
| 30 | return 1; |
| 31 | } |
Jonathan Nieder | c0f19bf | 2011-04-20 05:35:08 -0500 | [diff] [blame] | 32 | if (!strcmp(argv[1], "run-command")) |
| 33 | exit(run_command(&proc)); |
Johannes Sixt | 2b541bf | 2010-01-10 14:11:22 +0100 | [diff] [blame] | 34 | |
| 35 | fprintf(stderr, "check usage\n"); |
| 36 | return 1; |
| 37 | } |