You are accidentially calling the thread's main function
You have:
pthread_create(&test_thread, NULL, test_thread_function(), NULL);
You need:
pthread_create(&test_thread, NULL, test_thread_function, NULL);
You need to pass in the pointer to the function. What you do instead is calling the function and then passing in the return value. Which would usually segfault if it wouldn't deadlock before
Bonus tip: you should use stderr, not stdout to print debug messages in timing-critical situations, because stdout will buffer.
However, be advised that any use of streams will change the timing and locking behavior of the program dramatically - because the I/O will lock the streams and hence synchronise the threads where an i/o free run wouldn't. So you program may work with debug prints but screw up without them.