Skip to content

Commit 8eb4c57

Browse files
committed
ci: run tests in Travis Ci
- download and build micropython and binutils-esp32 - run existing test cases using micropython - build files under tests/compat/*.S using both tools and compare - one simple test case (tests/compat/alu.S) included See #13
1 parent 71a04ee commit 8eb4c57

File tree

5 files changed

+135
-0
lines changed

5 files changed

+135
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tests/compat/*.bin
2+
tests/compat/*.elf
3+
tests/compat/*.o
4+
tests/compat/*.ulp
5+
.DS_Store

.travis.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
language: c
2+
dist: trusty
3+
sudo: false
4+
addons:
5+
apt:
6+
packages:
7+
- libffi-dev
8+
- pkg-config
9+
10+
11+
script:
12+
- export VER=$(git describe --always --tags)
13+
- echo ${VER}
14+
15+
###### Install tools ######
16+
17+
- echo "Building micropython"
18+
- git clone --recursive https://github.com/micropython/micropython.git
19+
- pushd micropython/ports/unix
20+
- git describe --always --tags
21+
- make axtls
22+
- make
23+
- export PATH=$PATH:$PWD
24+
- test $(micropython -c 'print("test")') = "test"
25+
- popd
26+
27+
- echo "Building binutils-esp32ulp"
28+
- git clone https://github.com/espressif/binutils-esp32ulp.git
29+
- pushd binutils-esp32ulp
30+
- git describe --always --tags
31+
- ./configure --target=esp32ulp-elf --prefix=$PWD/dist --disable-doc --disable-gdb --disable-libdecnumber --disable-readline --disable-sim
32+
- echo "MAKEINFO = :" >> Makefile
33+
- make
34+
- make install-strip
35+
- export PATH=$PATH:$PWD/dist/bin
36+
- esp32ulp-elf-as --version | grep 'esp32ulp-elf' > /dev/null
37+
- popd
38+
39+
###### Run tests ######
40+
41+
- pushd tests
42+
- ./00_run_tests.sh
43+

tests/00_run_tests.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
1+
#!/bin/bash
2+
13
# export PYTHONPATH=.:$PYTHONPATH
24

5+
set -e
6+
37
for file in opcodes assemble link ; do
48
echo testing $file...
59
micropython $file.py
610
done
711

12+
for src_file in $(ls -1 compat/*.S); do
13+
src_name="${src_file%.S}"
14+
15+
echo "Building $src_file using py-esp32-ulp"
16+
ulp_file="${src_name}.ulp"
17+
micropython -m esp32_ulp $src_file # generates $ulp_file
18+
19+
obj_file="${src_name}.o"
20+
elf_file="${src_name}.elf"
21+
bin_file="${src_name}.bin"
22+
23+
echo "Building $src_file using binutils"
24+
esp32ulp-elf-as -o $obj_file $src_file
25+
esp32ulp-elf-ld -T esp32.ulp.ld -o $elf_file $obj_file
26+
esp32ulp-elf-objcopy -O binary $elf_file $bin_file
27+
28+
if ! diff $ulp_file $bin_file; then
29+
echo "Compatibility test failed for $src_file"
30+
echo "py-esp32-ulp output:"
31+
hexdump $ulp_file
32+
echo "binutils output:"
33+
hexdump $bin_file
34+
exit 1
35+
else
36+
echo "Build outputs match for $src_file"
37+
fi
38+
done

tests/compat/alu.S

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.text
2+
3+
and r1, r2, r3
4+
and r3, r0, 0xffff
5+
and r1, r1, 0xa5a5
6+
7+
or r1, r2, r3
8+
or r3, r0, 0xffff
9+
or r1, r1, 0xa5a5
10+
11+
add r1, r1, 32767
12+
add r0, r3, -32768
13+
add r3, r0, -1
14+
add r2, r1, 1
15+
16+
sub r1, r1, 32767
17+
sub r0, r3, -32768
18+
sub r3, r0, -1
19+
sub r2, r1, 1
20+
21+

tests/esp32.ulp.ld

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
ULP_BIN_MAGIC = 0x00706c75;
2+
HEADER_SIZE = 12;
3+
CONFIG_ULP_COPROC_RESERVE_MEM = 4096;
4+
5+
MEMORY
6+
{
7+
ram(RW) : ORIGIN = 0, LENGTH = CONFIG_ULP_COPROC_RESERVE_MEM
8+
}
9+
10+
SECTIONS
11+
{
12+
.text : AT(HEADER_SIZE)
13+
{
14+
*(.text)
15+
} >ram
16+
.data :
17+
{
18+
. = ALIGN(4);
19+
*(.data)
20+
} >ram
21+
.bss :
22+
{
23+
. = ALIGN(4);
24+
*(.bss)
25+
} >ram
26+
27+
.header : AT(0)
28+
{
29+
LONG(ULP_BIN_MAGIC)
30+
SHORT(LOADADDR(.text))
31+
SHORT(SIZEOF(.text))
32+
SHORT(SIZEOF(.data))
33+
SHORT(SIZEOF(.bss))
34+
}
35+
}

0 commit comments

Comments
 (0)