The only way to detect an emulator that doesn't use emulator ID (all modern ones) is to exploit a difference between that emulator and real hardware. This only works until the emulator gets fixed.
Writing such code is useful only insofar as it helps emulators improve, by providing a test case.
The floating line test has false positives when used to detect ...
Most — if not all — CSDB demos expect a PAL C64. VICE or TheC64 (which should be referred to as “Hall of Shame VICE”) typically start up as NTSC.
This demo seems to run adequately in VICE 3.5 for me when invoked with:
x64sc --model pal KRESTAGE3.D64
ZX65SIM aka 6502SIM is a 6502 simulator for a Z80 CP/M system, written in 1982. It's designed for debugging / stepping 6502 code rather than to emulate a particular system, and simulates only the processor with no I/O.
The Commodore 64 hosted a number of pure software emulators back in the day:
Commodore itself published a Commodore PET Emulator, written by Bob Fairbairn and bearing a copyright date of 1982. The program reconfigures the C64 to act like a 40-column PET 2001, including the memory configuration and sound. According to the manual, "machine language ...
There's a number of (pure software) ZX Spectrum Emulators on the Sinclair QL if you count that as an 8-bit machine (quite obvious, as many QL owners were upgrading from a Spectrum), and there is a combined hard-/software emulator of the same ZX Spectrum for the Enterprise 64/128 computer.
The Modcomp minicomputers were shipped with extensive self-test programs (on nine-track magnetic tape, no less). These were stand-alone programs (no operating system needed) that tested everything from peripherals to memory to CPU.
The CPU tests were in a series, starting with "is it working at all" tests. Each test confirmed a more complex part ...
Throwing some things out there that might fit the bill:
6502: AllSuiteA which assembles into a single binary and exits, leaving a failure or success code in memory;
6502 and 65C02: Klaus Dormann's test suite also compiles into a single binary per target CPU, but loops in place if it finds an error rather than exiting;
6502: Wolfgang Lorenz's tests cover the ...
I understand the question (now), as asking about self test programs to check a CPU (or its emulation) for correct operation by trying out certain instructions and verifying the results. Does this fit?
Such were plenty. In The Early Days (tm) magazines like Byte, Kilobaud or Micro published such for many new CPUs. It was a very common finger exercise for ...