Under EASA, a single pilot aeroplane, which I assume we are discussing here, has only one commander. If it is an instructional flight the instructor is P1 and the student is Pu/t. (Pilot under training)
If a flight test and you pass you can log P1.
As far as I am aware EASA do not recognise the term safety pilot, only an instructor or examiner can also log the time as P1, another pilot going along to keep a look out is a passenger.