aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
Diffstat (limited to 'sim')
-rw-r--r--sim/testsuite/cris/c/openpf1.c8
-rw-r--r--sim/testsuite/cris/c/stat3.c3
2 files changed, 7 insertions, 4 deletions
diff --git a/sim/testsuite/cris/c/openpf1.c b/sim/testsuite/cris/c/openpf1.c
index 92d12bf..37940d7 100644
--- a/sim/testsuite/cris/c/openpf1.c
+++ b/sim/testsuite/cris/c/openpf1.c
@@ -3,8 +3,8 @@
We assume, with EXE being the name of the executable:
- The simulator executes with cwd the same directory where the executable
- is located (so argv[0] contains a plain filename without directory
- components).
+ is located (also argv[0] contains a plain filename without directory
+ components -or- argv[0] contains the full non-sysroot path to EXE).
- There's no /EXE on the host file system. */
#include <stdio.h>
@@ -21,8 +21,10 @@ int main (int argc, char *argv[])
if (fnam == NULL)
abort ();
strcpy (fnam, "/");
- strcat (fnam, basename (argv[0]));
+ strcat (fnam, argv[0]);
}
+ else
+ fnam = strrchr (argv[0], '/');
f = fopen (fnam, "rb");
if (f == NULL)
diff --git a/sim/testsuite/cris/c/stat3.c b/sim/testsuite/cris/c/stat3.c
index eac4da9..f7c9604 100644
--- a/sim/testsuite/cris/c/stat3.c
+++ b/sim/testsuite/cris/c/stat3.c
@@ -7,13 +7,14 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#define mybasename(x) ({ const char *x_ = (x), *y_ = strrchr (x_, '/'); y_ != NULL ? y_ + 1 : x_; })
int main (int argc, char *argv[])
{
char path[1024] = "/";
struct stat buf;
- strcat (path, basename (argv[0]));
+ strcat (path, mybasename(argv[0]));
if (stat (".", &buf) != 0
|| !S_ISDIR (buf.st_mode))
abort ();