0

I would like to automate some test cases running on IA-32 x86 architecture based target, Some of these test cases generates a general protection Fault ( expected result as a part of the validation process). I would like to know if there is a way to recover from this fault and proceed with the rest of the test cases. If not what are other potential way for the automation of the tests?

too honest for this site
  • 12,050
  • 4
  • 30
  • 52
Keith Ape
  • 1,103
  • 1
  • 12
  • 28
  • Yes, but depends on your environment. – Jester Mar 17 '16 at 19:19
  • I am working on ubuntu 64-bit , and using GNU toolchain. – Keith Ape Mar 17 '16 at 19:34
  • 2
    The safe bet is to run the test in a separate process (you can simply `fork()`) which you can `ptrace` to detect and analyze the fault. – Jester Mar 17 '16 at 19:37
  • I am runing the tests on a target hardware ( Quark Se based board- with an x86 core ) , I have to flash the tests on the board and see results through a serial port, I want to recover from a fault on the hardware... – Keith Ape Mar 17 '16 at 19:41
  • Not sure what you mean, you said you were running ubuntu. So, you have processes and ptrace. What's the problem? – Jester Mar 17 '16 at 19:52
  • i am developing on linux Ubuntu but i am running my code on a hardware target (Interl Quark_se) .. sorry got you wrong – Keith Ape Mar 17 '16 at 20:01
  • 3
    Assuming your code is running completely on the bare metal, no OS of any sort, then you'd need install a GP fault handler in the IDT and that handler would then have to somehow resume execution in a way that would allow the next test to execute. Exactly how you'd do that depends on a lot of details, like whether your code is running in real mode or protected mode. – Ross Ridge Mar 17 '16 at 20:45
  • Hello @RossRidge , I am running in protected mode.. my code is running on the bare metal, and I already installed a GP fault handler, when a GP fault happends the handler is excuted but I cant think of a proper mechanism to resume tests from the handler ... for example should I jump to the next test function from my handler and modify my EIP, CS, etc ... or what do you think should i do from the handler ? – Keith Ape Mar 19 '16 at 17:09
  • Is your test code running in ring 0 or ring 3? – Ross Ridge Mar 19 '16 at 17:34
  • @RossRidge depends.. I have some tests that have tasks running in ring 3 and some in ring 0 , as I mentioned I am doing some hardware validation so for example I have a test that do a permission violations "unprivileged Call from a task in ring 3 to a task in ring 0 " and as expected I get a GP fault , and then the handler get excuted ... at this point I want to save the test result "Ex: saying Test failed due to permission violation" and want to figure out someway to proced with next tests. – Keith Ape Mar 19 '16 at 17:53
  • Yah. that really complicates things. If it were all ring 3 code I would suggest maybe implementing a Unix-like signal interface and using `longjmp` in the signal handler to abort the test and move onto the next one. With it mixed like that it depends a lot on how you're actually running the tests, and from the sounds of things you may need multiple different strategies. At least two, one to handle the ring 0 tests and another for the ring 3 ones. – Ross Ridge Mar 19 '16 at 18:12

0 Answers0