build_table_filename() doesn't support temporary tables. Indeed, it always builds the path as datadir/db_name/table_name, while temporary tables are in the tmpdir. This shows up in various DDL statements that use temporary tables:
This fails. Or
This test case succeeds but leaves an orphant temporary frm in the tmpdir (and it causes a warning on restart).
Note: when this is fixed, please uncomment the corresponding test in innodb-fk-warnings.test