Arduino Mega2560 and expander MCP23017

A Mega should be able to test 27 cables with the discrete pins.

some years ago I have written a short POC.
It tests each cable if it is connected to another cable: