From 3bad293d5ce6165493131e60c227f9cc910849fc Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Sat, 17 Sep 2011 07:13:49 +0300 Subject: [PATCH] the beginnings of a test harness --- tests/run_tests.py | 45 ++++++++++++++++++++++++++++++++++++++ tests/testfiles/z32.elf | Bin 0 -> 5492 bytes tests/testfiles/z32.o.elf | Bin 0 -> 667 bytes 3 files changed, 45 insertions(+) create mode 100755 tests/run_tests.py create mode 100755 tests/testfiles/z32.elf create mode 100644 tests/testfiles/z32.o.elf diff --git a/tests/run_tests.py b/tests/run_tests.py new file mode 100755 index 0000000..b86b3bf --- /dev/null +++ b/tests/run_tests.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +#------------------------------------------------------------------------------- +# tests/run_tests.py +# +# Automatic test runner for elftools & readelf +# +# Eli Bendersky (eliben@gmail.com) +# This code is in the public domain +#------------------------------------------------------------------------------- +import os, sys +import subprocess + + +def discover_testfiles(rootdir): + """ Discover test files in the given directory. Yield them one by one. + """ + for filename in os.listdir(rootdir): + _, ext = os.path.splitext(filename) + if ext == '.elf': + yield os.path.join(rootdir, filename) + + +def die(msg): + print 'Error:', msg + sys.exit(1) + + +def is_in_rootdir(): + """ Check whether the current dir is the root dir of pyelftools + """ + dirstuff = os.listdir('.') + return 'tests' in dirstuff and 'elftools' in dirstuff + + +def main(): + if not is_in_rootdir(): + die('Please run me from the root dir of pyelftools!') + + +if __name__ == '__main__': + main() + print list(discover_testfiles('tests/testfiles')) + + + diff --git a/tests/testfiles/z32.elf b/tests/testfiles/z32.elf new file mode 100755 index 0000000000000000000000000000000000000000..d6b3cd1ff7e422d1845ec7887ccb1e0cb1db058c GIT binary patch literal 5492 zcmeHLUuauZ7(Z!mw^S=;Tg2kxh?;8q(7SHS#41i**R{p5zqTr+%hD!o?#Q2!d!rk4 z*e(`Y(n`T8eOrqUzNic)B6JTe8SCa#6ofrUndl&;Rr^rKz|rgPcW+L~Y6tq@TR!;C z_kHL4o$q|-JLiU+^Fi~Wg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GnB4Oy3eBe}QS3+|=$)&Yb2C5b)~`!<7#v)&}&@IsfwyEo|>u*5}hh9bcE zERWqt+)FTd-WZQ(aI}Eq*&`80_Ji-@oDjz|dKow`^!2!X=;K<5H zej5W&isNyuv~{q=@mm@Oj(Kxlezy|W51qNPpWpNZa1GEU5l4C-EO9r0yRiX|*b7BC zfp-HIDJqKrA9ElLgJnGahD0$KH}W--^L|voVLCAk+%OzmpCpO<6djC5+&FOKa7Z7q zQlErQ9QV$8Q^SMQM)5u`!tt@f{Se$&ML0f6cz~00!L_DefzBFpUhAz6xEyruFNtHA z$5pV*kMBXt8^j}awg|`H&=uhL`zeVS@^@ev&xuzSCpKWC^)eUsGe5q@xE_N0u@J8T Zl0@8dwraJUOEP0g+5_CYG$4r~{SC5E+|~d9 literal 0 HcmV?d00001 diff --git a/tests/testfiles/z32.o.elf b/tests/testfiles/z32.o.elf new file mode 100644 index 0000000000000000000000000000000000000000..5ce4182abc8e387e714b3716b2f8673c76ce092b GIT binary patch literal 667 zcma))&q~8U5XL7q))p_-tCtFb73?CIUc_68y@GU%k)&WYpuOl-y!aTthtJXn z@CkIjWJcGM4orUY&3?O?{CSMe&w?Nzjet7zqln&QA!<0HK6NR1UcJP<%XgYhrzgWv zlGdfGhmncQ@i?j*H92TCk*OXEXH%xTYk94e%kLeTE9)$ow5rHti=xO&?v)Fdo7qJ& zuAI$ob+-R-hfSEjD`w2ylNt!6-etnq5q&CDsBfPe*#DRBkUco>h!cVH_L{1_U=2AD zwq2sR7D9LsTbz1N=s9PMLPCAunl_mO7Eesfyupd*7;yGE{qtVgx5+&XJx{gL?}zm9 kseSPGp91Yq0`1=sdfng7I{f}ln0Fg*Xt^{Q751j2FLh!tJ^%m! literal 0 HcmV?d00001 -- 2.30.2