Australia face a test of their mettle on the final day of the opening Test against South Africa.

Chasing a notional total of 539 to win in Perth, the home side know this is a salvation mission and will resume day five on 169 for four.

They are 370 short but that is largely irrelevant at this stage, with their main focus being how to deal with the brilliance of Kagiso Rabada.

Carrying the load in the absence of the injured Dale Steyn, Rabada swung the ball expertly and finished with figures of three for 49, accounting for Shaun Marsh, Steve Smith and Adam Voges.

The other Baggy Green wicket to fall was David Warner, the opener going to the most breathtaking piece of fielding by Temba Bavuma.

Looking menacing with 35 off 33 balls, Warner was Australia's best hope of pursuing a world-record chase and looked to keep the pressure on with a quick single into the on-side.

It looked a good bet, but he did not account for the outstanding reactions of Bavuma who swooped and threw down the stumps with a brilliant diving effort that some, including Michael Vaughan, say may be the best run-out of all-time.

Regardless of its place in history, the wicket rocked Australia.

Four balls later they were two down for 52 as Marsh was taken by Faf du Plessis in the slips off the bowling of Rabada, the delivery rearing up at the opener.

New batsman Usman Khawaja was nearly a first-ball casualty with the next delivery, initially given out caught behind off Keshav Maharaj before it was overturned on review, the ball clipping his pad and not his bat.

He was given another life on 41, put down by Hashim Amla at first slip, the fielder looking too wide and having to dive - unsuccessfully - to his right to try and snaffle the edge off Rabada.

Khawaja was able to move on and put together a fourth-wicket stand of 92 with captain Steve Smith which was broken when the later was taken behind by Quinton de Kock, Rabada's swing tying Smith in knots.

Voges did little to steady the ship, going the same way as Smith for one, adding to his woes after his costly drop of De Kock on day three. The ball that removed him followed four brilliant deliveries which pulled him in almost every direction.

His dropped catch was brought into focus more during the morning session.

Resuming on 390 for six, South Africa eventually declared on 540 for eight, with De Kock going on to make 64 and Vernon Philander 73, while Maharaj chipped in with a 34-ball 41.

Three Australian bowlers went for three figures as Mitchell Starc, Josh Hazlewood and Nathan Lyon were all given the treatment.