Skip to content

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 and atexit, 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, and ftell/fseek in text files.
  • tests/libc/random.c: getentropy, arc4random, arc4random_uniform and arc4random_buf. It runs twice, and the two runs must print different first values.
  • tests/libc/halloc.c: halloc and hfree blocks over 64 KiB next to malloc (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 from option stack, with heap blocks next to it (not built for tiny).
  • tests/libc/fsys.c: opendir and readdir, stat on directories, realpath, chmod, truncate, utime and statvfs (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_cast and typeid with -frtti.
  • tests/cxx/iohello.cpp: std::cout and std::cerr with strings and integers (tiny, small and compact).
  • tests/cxx/iobasic.cpp: std::cout, std::cin and std::cerr, string streams, integers and strings (small, at -Os and -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.cpp is built with -DEMU2, which skips file times and permissions).
  • tests/cxx/syncio.cpp: sync_with_stdio(false) and back keeps what cout and cin buffered, with wcout too in the models with far code (small at -Os and -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_ptr and std::uncaught_exceptions. NO_CXX=1 skips it.
  • tests/libc/intr.c: __interrupt handlers with union INTPACK and with Microsoft C parameters, called with INT (also with another DS), 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, int86 and intdos, and delay.
  • 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 -Os and in the far-code models). The graphics and window examples in examples/dos are built but not run, as they need a display; tests/dos/README.md shows how to run them in DOSBox. NO_DOSLIBS=1 skips them.
  • tests/builtins/rtt.c: 32 and 64-bit integer and soft float builtins against results computed on the host by tests/builtins/gen.py.

The resident program test runs in DOSBox, which keeps programs resident as DOS does (emu2 does not):

BIN=~/llvm-build/bin SYSROOT=$PWD/sysroot LD=/path/to/jwlink \
sh tests/run-tsr-tests.sh

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.