This is wrong. lwarx/stwcx work on word-sized entities. You are only
allocating a byte.
*testB = 0;
printf("testB is %d and stored at %d.\n Now locking.\n", *testB,
(int) testB);
_lock_(testB);
printf("testB is now %d\n", *testB);
It's normal that this prints 0, since you are on a big-endian system.
The byte at test+3 has been incremented by one (and depending on its
previous value, possibly also the bytes at test+2 and test+1 and in the
extreme case also at test).