[tests] Test loading references from LoadFrom and LoadFile contexts
[mono-project.git] / scripts / launch.c
blob4a1bd46b74718789b4b8362028d533b2abe9855c
1 #define PROFILE_BASE_DIR "/mono/lib/mono/4.0"
2 #define MONO_BINARY "/mono/bin/mono"
3 #include <stdio.h>
4 #include <string.h>
5 #include <unistd.h>
6 #include <malloc.h>
8 int
9 main (int argc, char *argv [])
11 char **nargv = (char **) malloc (sizeof (char *) * (argc + 1));
12 char *last = strrchr (argv [0], '/');
13 char *command;
14 int i, len;
16 if (last == NULL){
17 fprintf (stderr, "Do not know how to invoke the program given [%s]\n", argv [0]);
18 free (nargv);
19 return 1;
21 len = strlen (last) + strlen (PROFILE_BASE_DIR) + 1;
22 command = malloc (len);
23 if (command == NULL){
24 fprintf (stderr, "Error allocating memory");
25 free (nargv);
26 return 1;
28 strcpy (command, PROFILE_BASE_DIR);
29 strcat (command, last);
30 nargv [0] = command;
31 nargv [1] = command;
33 for (i = 1; i < argc; i++)
34 nargv [1+i] = argv [i];
36 execvp (MONO_BINARY, nargv);