Skip to content

Commit

Permalink
merge#89
Browse files Browse the repository at this point in the history
  • Loading branch information
wmacevoy committed Sep 9, 2019
2 parents 4ad93a1 + 60840b8 commit dbcfa8c
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 27 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@
* Provide preliminary Continuous Integration Testing support (ci)
## 3.0.2
* Data deduplication bug fix patch.
## 3.0.3
* Support for Teensy (#87)
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ Note that `Test::run()` only calls the active unresolved tests.

* The `assertCurrentTestXXXX([,footnote [,retval])` macros do not compile on ESP8266 boards with no footnote. Use an empty footnote `assertCurrentTestXXXX("")`, or use `assertCurrentTestXXXX_0()` for no footnote. You do not have to specify a return value.

* The current release prints "skipped" for all tests, although assertions are correctly reported. (#86)

## FAQ

Q. The line number of the asserts do not match the source file.
Expand Down
24 changes: 24 additions & 0 deletions ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,27 @@ A clean (except the ide cache which is pointless and slow) install can be starte
```bash
au reset
```

## debug

~Warning~ this is a hack. But stepping through code is amazingly useful. I have only tested it on Ubuntu; but should work on

1. Install simavr (sudo apt install simavr). This should also install avr-gcc.
1. Install this toolset in in Ubunutu: run `au arduino` to spin up the basic working cache of the ide.
1. Create and set the TMP environment variable so the system does not build and erase a temporary file. I used "<project>/tmpdir" and made that folder.
1. Compile the project with `au compile_avr` in the project directory. The build residue should be in TMP.
1. Look in the TMP directory, and find the build folder.
1. Open two terminals here; one to run the program and one to debug from.
1. In your run terminal, type
```bash
simavr -g -m atmega328p -f 16000000 basic.ino.elf
```
1. In your debug terminal, type `avr-gdb` to start the avr debugger, then in th prompts type
```bash
tui enable
file basic.ino.elf
target remote :1234
b setup
c
s
```
4 changes: 2 additions & 2 deletions ci/bin/compile_avr
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ compile_avr() {

mkdir -p "${ARDUINO_LIBS}"

${ARDUINO_DIR}/arduino-builder -dump-prefs -logger=machine -hardware ${ARDUINO_DIR}/hardware -hardware ${ARDUINO_DIR}/hardware -tools ${ARDUINO_DIR}/tools-builder -tools ${ARDUINO_DIR}/hardware/tools/avr -built-in-libraries ${ARDUINO_DIR}/libraries -libraries ${ARDUINO_LIBS} -fqbn=${BOARD} -ide-version=10802 -build-path ${TMP}/build -warnings=all -build-cache ${TMP}/cache -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=${ARDUINO_DIR}/hardware/tools/avr -prefs=runtime.tools.arduinoOTA.path=${ARDUINO_DIR}/hardware/tools/avr -prefs=runtime.tools.avrdude.path=${ARDUINO_DIR}/hardware/tools/avr -verbose "${TMP}/src/$(basename ${INO})" 2>&1 | sed -e "s|${TMP}/build/sketch/|${ARDUINO_TARGET_DIR}/|g"
${ARDUINO_DIR}/arduino-builder -dump-prefs -logger=machine -hardware ${ARDUINO_DIR}/hardware -hardware ${ARDUINO_DIR}/hardware -tools ${ARDUINO_DIR}/tools-builder -tools ${ARDUINO_DIR}/hardware/tools/avr -built-in-libraries ${ARDUINO_DIR}/libraries -libraries ${ARDUINO_LIBS} -fqbn=${BOARD} -ide-version=10802 -build-path ${TMP}/build -warnings=all -build-cache ${TMP}/cache -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=${ARDUINO_DIR}/hardware/tools/avr -prefs=runtime.tools.arduinoOTA.path=${ARDUINO_DIR}/hardware/tools/avr -prefs=runtime.tools.avrdude.path=${ARDUINO_DIR}/hardware/tools/avr -prefs="compiler.cpp.extra_flags=-g" -verbose "${TMP}/src/$(basename ${INO})" 2>&1 | sed -e "s|${TMP}/build/sketch/|${ARDUINO_TARGET_DIR}/|g"

${ARDUINO_DIR}/arduino-builder -compile -logger=machine -hardware ${ARDUINO_DIR}/hardware -hardware ${ARDUINO_HARDWARE} -tools ${ARDUINO_DIR}/tools-builder -tools ${ARDUINO_DIR}/hardware/tools/avr -built-in-libraries ${ARDUINO_DIR}/libraries -libraries ${ARDUINO_LIBS} -fqbn=${BOARD} -ide-version=10802 -build-path ${TMP}/build -warnings=all -build-cache ${TMP}/cache -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=${ARDUINO_DIR}/hardware/tools/avr -prefs=runtime.tools.arduinoOTA.path=${ARDUINO_DIR}/hardware/tools/avr -prefs=runtime.tools.avrdude.path=${ARDUINO_DIR}/hardware/tools/avr -verbose "${TMP}/src/$(basename ${INO})" 2>&1 | sed -e "s|${TMP}/build/sketch/|${ARDUINO_TARGET_DIR}/|g"
${ARDUINO_DIR}/arduino-builder -compile -logger=machine -hardware ${ARDUINO_DIR}/hardware -hardware ${ARDUINO_HARDWARE} -tools ${ARDUINO_DIR}/tools-builder -tools ${ARDUINO_DIR}/hardware/tools/avr -built-in-libraries ${ARDUINO_DIR}/libraries -libraries ${ARDUINO_LIBS} -fqbn=${BOARD} -ide-version=10802 -build-path ${TMP}/build -warnings=all -build-cache ${TMP}/cache -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=${ARDUINO_DIR}/hardware/tools/avr -prefs=runtime.tools.arduinoOTA.path=${ARDUINO_DIR}/hardware/tools/avr -prefs=runtime.tools.avrdude.path=${ARDUINO_DIR}/hardware/tools/avr -prefs="compiler.cpp.extra_flags=-g" -verbose "${TMP}/src/$(basename ${INO})" 2>&1 | sed -e "s|${TMP}/build/sketch/|${ARDUINO_TARGET_DIR}/|g"
if [ ! -f "${TMP_HEX}" ] ; then
echo "compile time error: avr."
exit 1
Expand Down
8 changes: 4 additions & 4 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=ArduinoUnit
version=3.0.2
author=Matthew Murdoch
maintainer=Matthew Murdoch <matthew.murdoch.0@gmail.com>
version=3.0.3
author=Warren MacEvoy
maintainer=Warren MacEvoy <wmacevoy@gmail.com>
sentence=Flexible test framework for arduino projects.
paragraph=Flexible testing framework for arduino projects. Supports Arduino, ESP8266 and ESP32 as well as "en vitro" development system (vs embedded target) testing.
paragraph=Flexible testing framework for arduino projects. Supports Arduino, ESP8266 and ESP32 as well as "en vitro" development system (vs embedded target) testing. Based on Arduino Unit 1.0 by Matthew Murdoch.
category=Other
url=https://github.com/mmurdoch/arduinounit
architectures=*
46 changes: 29 additions & 17 deletions src/ArduinoUnitUtility/ArduinoUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ static CppStreamPrint Serial;

Print* Test::out = &Serial;

#if ARDUINO_UNIT_USE_FLASH > 0
#define ARDUINO_UNIT_PROGMEM PROGMEM
#else
#define ARDUINO_UNIT_PROGMEM
#endif

const char CONST_SKIPPED[] ARDUINO_UNIT_PROGMEM = "skipped";
const char CONST_PASSED[] ARDUINO_UNIT_PROGMEM = "passed";
const char CONST_FAILED[] ARDUINO_UNIT_PROGMEM = "failed";

ARDUINO_UNIT_DECLARE_STRING SKIPPED = (ARDUINO_UNIT_DECLARE_STRING) CONST_SKIPPED;
ARDUINO_UNIT_DECLARE_STRING PASSED = (ARDUINO_UNIT_DECLARE_STRING) CONST_PASSED;
ARDUINO_UNIT_DECLARE_STRING FAILED = (ARDUINO_UNIT_DECLARE_STRING) CONST_FAILED;

void Test::noMessage(bool ok) { (void) ok; }

Expand All @@ -38,11 +51,12 @@ void Test::resolve()
bool fail = state==DONE_FAIL;
bool skip = state==DONE_SKIP;
bool done = (pass || fail || skip);
ARDUINO_UNIT_DECLARE_STRING message = 0;

if (done) {
if (pass) ++Test::passed;
if (fail) ++Test::failed;
if (skip) ++Test::skipped;
if (pass) { message=PASSED; ++Test::passed; }
if (fail) { message=FAILED; ++Test::failed; }
if (skip) { message=SKIPPED; ++Test::skipped; }

#if TEST_VERBOSITY_EXISTS(TESTS_SKIPPED) || TEST_VERBOSITY_EXISTS(TESTS_PASSED) || TEST_VERBOSITY_EXISTS(TESTS_FAILED)

Expand All @@ -55,29 +69,27 @@ void Test::resolve()
if (output) {
Test::out->print(ARDUINO_UNIT_STRING("Test "));
Test::out->print(name);
#if TEST_VERBOSITY_EXISTS(TESTS_SKIPPED)
if (skip) { Test::out->println(ARDUINO_UNIT_STRING(" skipped.")); }
#endif

#if TEST_VERBOSITY_EXISTS(TESTS_PASSED)
if (pass) { Test::out->println(ARDUINO_UNIT_STRING(" passed.")); }
#endif

#if TEST_VERBOSITY_EXISTS(TESTS_FAILED)
if (fail) { Test::out->println(ARDUINO_UNIT_STRING(" failed.")); }
#endif
Test::out->print(' ');
Test::out->print(message);
Test::out->println();
}
#endif
}
#if TEST_VERBOSITY_EXISTS(TESTS_SUMMARY)
if (root == 0 && TEST_VERBOSITY(TESTS_SUMMARY)) {
Test::out->print(ARDUINO_UNIT_STRING("Test summary: "));
Test::out->print(passed);
Test::out->print(ARDUINO_UNIT_STRING(" passed, "));
Test::out->print(' ');
Test::out->print(PASSED);
Test::out->print(ARDUINO_UNIT_STRING(", "));
Test::out->print(failed);
Test::out->print(ARDUINO_UNIT_STRING(" failed, and "));
Test::out->print(' ');
Test::out->print(FAILED);
Test::out->print(ARDUINO_UNIT_STRING(", "));
Test::out->print(skipped);
Test::out->print(ARDUINO_UNIT_STRING(" skipped, out of "));
Test::out->print(' ');
Test::out->print(SKIPPED);
Test::out->print(ARDUINO_UNIT_STRING(", out of "));
Test::out->print(count);
Test::out->println(ARDUINO_UNIT_STRING(" test(s)."));
}
Expand Down
9 changes: 8 additions & 1 deletion src/ArduinoUnitUtility/ArduinoUnitMockPrint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,12 @@ MockPrint::MockPrint(const String &_initial) : String(_initial) {}
MockPrint::~MockPrint() {}

size_t MockPrint::write(uint8_t x) { concat((char) x); return 1; }
size_t MockPrint::write(const uint8_t *buffer, size_t size) { concat((const char *)buffer,size); return size; }
size_t MockPrint::write(const uint8_t *buffer, size_t size) {
#ifdef TEENSYDUINO
append((const char *)buffer, size);
#else
concat((const char *)buffer, size);
#endif // TEENSYDUINO
return size;
}
int MockPrint::availableForWrite() { return INT_MAX; }
6 changes: 3 additions & 3 deletions src/ArduinoUnitUtility/Flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
# define ARDUINO_UNIT_PSTR(str) \
(__extension__({ \
PGM_P ptr; \
PGM_P ptr ## __COUNTER__; \
asm volatile \
( \
".pushsection .progmem.mergeable-strings, \"SM\", @progbits, 1" "\n\t" \
Expand All @@ -21,9 +21,9 @@
( \
"ldi %A0, lo8(0b)" "\n\t" \
"ldi %B0, hi8(0b)" "\n\t" \
: "=d" (ptr) \
: "=d" (ptr ## __COUNTER__) \
); \
ptr; \
ptr ## __COUNTER__ ; \
}))
# define ARDUINO_UNIT_STRING(STR) (reinterpret_cast<const __FlashStringHelper *>(ARDUINO_UNIT_PSTR(STR)))
# define ARDUINO_UNIT_DECLARE_STRING const __FlashStringHelper *
Expand Down

0 comments on commit dbcfa8c

Please sign in to comment.