The government emmissions test doesn’t measure what comes out of the tail pipe?
There are visual inspections, but, they're not terribly thorough, and they don't disassemble anything.
That's for normal cars mind, for diesel semis/lori's they also have a measure of how much smoke comes out of the stacks at a given load, and how long it lingers in the air, so even if the ECU reads clean, if it's running dirty like that it'll still fail.