1*4b169a6bSchristos /* Test some execution paths for error cases. 2*4b169a6bSchristos #cc: additional_flags=-Wl,--section-start=.startup=0x8000 3*4b169a6bSchristos The linker option is for sake of newlib, where the default program 4*4b169a6bSchristos layout starts at address 0. We need to change the layout so 5*4b169a6bSchristos there's no memory at 0, as all sim error checking is "lazy", 6*4b169a6bSchristos depending on lack of memory mapping. */ 7*4b169a6bSchristos 8*4b169a6bSchristos #include <stdio.h> 9*4b169a6bSchristos #include <stdlib.h> 10*4b169a6bSchristos #include <errno.h> 11*4b169a6bSchristos err(const char * s)12*4b169a6bSchristosvoid err (const char *s) 13*4b169a6bSchristos { 14*4b169a6bSchristos perror (s); 15*4b169a6bSchristos abort (); 16*4b169a6bSchristos } 17*4b169a6bSchristos main(int argc,char * argv[])18*4b169a6bSchristosint main (int argc, char *argv[]) 19*4b169a6bSchristos { 20*4b169a6bSchristos if (rename (argv[0], NULL) != -1 21*4b169a6bSchristos || errno != EFAULT) 22*4b169a6bSchristos err ("rename 1 "); 23*4b169a6bSchristos 24*4b169a6bSchristos errno = 0; 25*4b169a6bSchristos 26*4b169a6bSchristos if (rename (NULL, argv[0]) != -1 27*4b169a6bSchristos || errno != EFAULT) 28*4b169a6bSchristos err ("rename 2"); 29*4b169a6bSchristos 30*4b169a6bSchristos printf ("pass\n"); 31*4b169a6bSchristos return 0; 32*4b169a6bSchristos } 33