The illuminated check engine light on your Mazda will definitely cause it to
fail the smog check; the oil smell from the muffler maybe not. The check
engine light being on is an automatic failure, so we have to recommend you
get that fixed first.
As far as the oil smell... In itself, it's not a smog check failure, unless
along with the smell there is visible smoke. A visible smoke test is part of
the smog inspection process. If the smog technician notices black smoke,
even if it's very little, he or she will have to fail your Mazda. The other
problem with oil smell which may cause a smog check failure is the cause of
the oil smell. You mentioned a possible head gasket leak. If in fact your
Mazda has a head gasket leak, more then likely the emissions which the smog
machine (smog test) is looking at HC, CO, and NOx will be too high to pass
the smog test. For one, mixing oil with fuel in the combustion chamber will
cause the fuel to not burn completely; leaving behind high levels of CO and
HC. Second problem with a headgasket leak is overheating. If your vehicle is
experience this problem more then likely it is producing high NOx emissions.
This too will cause a smog inspection failure.
We have to recommend you have your Mazda running good and
strong with no noticeable engine problems before getting a smog check. More
then likely the trouble codes stored in your Mazda's engine computer due to
the check engine light being illuminated, will direct a smog mechanic to
what needs to be fixed.