pcb,
the ECU , consistently runs a "Self-Diagnostic Test" every time you start the vehicle.( well, it is supposed to.)
If the ECU detects a fault, it trips a DTC. If the ECU does not detect a sensor that normally it detects, it will trip a fault code(DTC).
There are different kinds of DTC's. "One Trip" & "Two Trip"
A "one trip" fault will trip a DTC when a detected fault happens ONCE in a predetermined amount of time.(usually one drive cycle)
A "two trip" fault will trip a DTC when a fault is detected TWICE in a predetermined amount of time. (again, usually one drive cycle).
That's a simple explanation, there is more to it than that. (the newer the vehicle, the more evolved the ECU is with the car. It gets into "CAN-BUS" Communications, pre-set parameters, secondary modules, and on and on and on).
So with THAT in mind, your ECU should detect if the Knock Sensor (or any sensor for that matter) isn't doing its job. Provided that all communications wires are intact and all is working properly, etc...etc...