Tests¶
BIN=~/llvm-build/bin SYSROOT=$PWD/sysroot LD=/path/to/jwlink \
EMU2=/path/to/emu2 sh tests/run-tests.sh
This builds each test for each model at -O0, -Os and -O2 and runs
it in emu2:
tests/libc/libc.c: malloc, printf and strtod, qsort, setjmp, files, directories, constructors, destructors andatexit, environment, time.tests/libc/hello.c: command-line arguments.tests/libc/stdin.c: reading lines from standard input.tests/libc/textmode.c: text and binary files,O_TEXT,O_BINARY,_fmode,setmode, andftell/fseekin text files.tests/libc/random.c:getentropy,arc4random,arc4random_uniformandarc4random_buf. It runs twice, and the two runs must print different first values.tests/libc/halloc.c:hallocandhfreeblocks over 64 KiB next tomalloc(not built for tiny).tests/libc/nearfar.c: the far string functions, the near and far heaps, and the standard names with near and far pointers, as C and as C++ (also on Windows).tests/libc/bigstack.c: a 16 KiB stack fromoption stack, with heap blocks next to it (not built for tiny).tests/libc/fsys.c:opendirandreaddir,staton directories,realpath,chmod,truncate,utimeandstatvfs(built with-DEMU2, which skips the checks that emu2 does not support: it does not set file attributes or times).tests/cxx/cxx.cpp: virtual functions,vector,unique_ptr,shared_ptr,std::function,string,map,sort, function-local statics and global constructors and destructors.tests/cxx/oop.cpp: inheritance,dynamic_castandtypeidwith-frtti.tests/cxx/iohello.cpp:std::coutandstd::cerrwith strings and integers (tiny, small and compact).tests/cxx/iobasic.cpp:std::cout,std::cinandstd::cerr, string streams, integers and strings (small, at-Osand-O2).tests/cxx/iostream.cpp,tests/cxx/wchar.cpp,tests/cxx/fs.cpp: all of iostreams with file streams, manipulators and floating point; wide strings and streams,<cwchar>and the locale's facets;<filesystem>(medium, large, huge and huge16;fs.cppis built with-DEMU2, which skips file times and permissions).tests/cxx/syncio.cpp:sync_with_stdio(false)and back keeps whatcoutandcinbuffered, withwcouttoo in the models with far code (small at-Osand-O2; medium, large, huge and huge16).tests/cxx/demangle.cpp:abi::__cxa_demangle(medium, large, huge and huge16).tests/cxx/except.cpp: exceptions with-fexceptions: throwing and catching by type and base class, destructors during unwinding, rethrow,catch (...), constructors that throw,std::out_of_range,std::bad_alloc,std::exception_ptrandstd::uncaught_exceptions.NO_CXX=1skips it.tests/libc/intr.c:__interrupthandlers withunion INTPACKand with Microsoft C parameters, called with INT (also with anotherDS), through a pointer and with_chain_intr, and a timer interrupt handler that interrupts the program while it computes.tests/dos/conio.c:<conio.h>text windows, colors and screen copies,int86andintdos, anddelay.tests/dos/cwin.c:<cwin.h>windows, messages, controls, menus, painting into video memory, and a modal dialog and a message box driven by keys (in small at-Osand in the far-code models). The graphics and window examples inexamples/dosare built but not run, as they need a display; tests/dos/README.md shows how to run them in DOSBox.NO_DOSLIBS=1skips them.tests/builtins/rtt.c: 32 and 64-bit integer and soft float builtins against results computed on the host bytests/builtins/gen.py.
The resident program test runs in DOSBox, which keeps programs resident as DOS does (emu2 does not):
tests/tsr/tsr.c hooks INT 60h and the clock (INT 1Ch, chained) and stays
resident with _dos_keep(0, 0), in each model at -O0 and -Os; then
tests/tsr/check.c fills all the free DOS memory, which would overwrite
the resident program if it kept too little, and calls INT 60h twice.
The 16-bit Windows tests, which run in Wine, are in clang-dos/win16-sdk
(tests/run-tests.sh), and the 32-bit Windows ones in clang-dos/win32-sdk.