@@ -382,6 +382,9 @@ static bool runtime_test_copy_executable(const char *source, const char *destina
382382 return ok ;
383383}
384384
385+ /* PATH must be a copy of this runner: the child runs the
386+ * __cbm_runtime_image_holder mode, which blocks reading the release pipe
387+ * wired to its stdin. */
385388static pid_t runtime_test_spawn_blocked_executable (const char * path , int * release_fd_out ) {
386389 int ready [2 ] = {-1 , -1 };
387390 int input [2 ] = {-1 , -1 };
@@ -427,7 +430,7 @@ static pid_t runtime_test_spawn_blocked_executable(const char *path, int *releas
427430 if (input [0 ] != STDIN_FILENO ) {
428431 (void )posix_spawn_file_actions_addclose (& actions , input [0 ]);
429432 }
430- char * const child_argv [] = {(char * )path , NULL };
433+ char * const child_argv [] = {(char * )path , "__cbm_runtime_image_holder" , NULL };
431434 pid_t child = -1 ;
432435 if (posix_spawn (& child , path , & actions , NULL , child_argv , environ ) != 0 ) {
433436 child = -1 ;
@@ -4518,10 +4521,20 @@ TEST(daemon_runtime_process_fingerprint_never_hashes_replacement_path) {
45184521 int replacement_written =
45194522 setup ? snprintf (replacement_path , sizeof (replacement_path ), "%s/replacement" , directory )
45204523 : -1 ;
4524+ /* The copied image is this runner in holder mode, not a system utility:
4525+ * a multi-call coreutils /bin/cat (uutils) prints "unknown program" and
4526+ * exits when executed under the copied name. */
45214527 setup = setup && image_written > 0 && image_written < (int )sizeof (image_path ) &&
45224528 replacement_written > 0 && replacement_written < (int )sizeof (replacement_path ) &&
4523- runtime_test_copy_executable ("/bin/cat" , image_path ) &&
4524- runtime_test_copy_executable ("/bin/echo" , replacement_path );
4529+ runtime_test_copy_self_image (image_path );
4530+
4531+ FILE * replacement_file = setup ? cbm_fopen (replacement_path , "wb" ) : NULL ;
4532+ bool replacement_written_ok =
4533+ replacement_file && fputs ("cbm-posix-replacement-image" , replacement_file ) >= 0 ;
4534+ if (replacement_file ) {
4535+ replacement_written_ok = fclose (replacement_file ) == 0 && replacement_written_ok ;
4536+ }
4537+ setup = setup && replacement_written_ok ;
45254538
45264539 char original [CBM_DAEMON_BUILD_FINGERPRINT_SIZE ] = {0 };
45274540 char replacement [CBM_DAEMON_BUILD_FINGERPRINT_SIZE ] = {0 };
0 commit comments