Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit simAVR with a non-zero exit code, triggered by the atMega program (for unittests) #362

Open
cdwijs opened this issue Jan 20, 2020 · 2 comments

Comments

@cdwijs
Copy link

cdwijs commented Jan 20, 2020

Hi All,

I would like to exit simAVR with a non-zero exit code, for instance if a byte in the atMega is non-zero. This would allow me to remotely run unit tests in a simulated atMega32, and have failed reports be reported back to me. Maybe this can be done by defining a new simAVR command like SIMAVR_CMD_TERMINATE_NONZERO.

Here's the workflow I'm trying to setup. Step 9 does not work, as simAVR always terminates with a zero exit code.

  1. On a windows PC, I write a source code in C for my atMega32 microcontroller.
  2. I push the source code to a Gitlab server
  3. The gitlab server parses a special file in the root of the source code (.gitlab-ci.yml), starts a docker container, and runs the test script in the docker container.
  4. In the docker container, the test script compiles the source code into an atMega32 program.
  5. In the docker container, the test script runs simAVR. simAVR runs the atMega32 program.
  6. In simAVR, the atMega program runs a series of unit tests, and reports to the serial port. simAVR forwards the data from the atMega program to it's standard output.
  7. When the atMega program is finished, it calls sleep_cpu(); This causes simAVR also to close.
  8. the test script also ends, the output from the test script is send back to the Gitlab server, and the docker container is destroyed.
  9. If the test script ends with a non-zero exit code, the Gitlab server considers the test as failed, and sends an e-mail to me with the output from the test script.

I'm using the current version of simavr, commit ab4c17c
https://github.com/buserror/simavr/tree/ab4c17cad37f33e956d625178a9904fc7c3056c2

Cheers,
Cedric de Wijs

@cdwijs
Copy link
Author

cdwijs commented Jan 21, 2020

I've implemented 2 extra commands, one that ends run_avr with an exit code of 0, and one that ends run_avr with an exit code of 1. The code is crude, but it is sufficient for my use case.

I've submitted this pull request with my code:
#363

@edgar-bonet
Copy link

Note that Gitlab cares about the exit code of the test script, not the one of simavr. The test script could parse the output of the ATmega32 program (forwarded by simavr) and set its own exit code accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants