Deleting the only file that starts a program leaves no Process node * behind -- a full index never makes one without a SPAWNS edge. One script * (pass_shell.c) and one Python call (pass_spawns.c) start programs; the * program a kept script starts stays. * - `legacy`: both go at once, through the full-load route. * - otherwise in two steps: the script alone goes through closure repair, * th
| 3775 | * of the first (or only) step; *after_script and *python_route: the count and |
| 3776 | * the route after the script-only step and the Python step (two-step mode). */ |
| 3777 | static int incremental_spawner_delete(bool legacy, cbm_incremental_route_t *route, |
| 3778 | int *after_script, cbm_incremental_route_t *python_route) { |
| 3779 | char tmp[256]; |
| 3780 | snprintf(tmp, sizeof(tmp), "/tmp/cbm_spawngc_XXXXXX"); |
| 3781 | if (!cbm_mkdtemp(tmp)) { |
| 3782 | return -1; |
| 3783 | } |
| 3784 | write_temp_file(tmp, "hack/a.sh", "#!/bin/sh\n./bin/tool-a --x\n"); |
| 3785 | write_temp_file(tmp, "hack/b.sh", "#!/bin/sh\n./bin/tool-b\n"); |
| 3786 | write_temp_file(tmp, "app.py", |
| 3787 | "import subprocess\n\n\ndef run():\n subprocess.run([\"tool-c\"])\n"); |
| 3788 | char db_path[512]; |
| 3789 | snprintf(db_path, sizeof(db_path), "%s/spawngc.db", tmp); |
| 3790 | static const char processes[] = "SELECT COUNT(*) FROM nodes WHERE label='Process'"; |
| 3791 | int full = k8s_inc_index(tmp, db_path) == 0 ? k8s_inc_count(db_path, processes) : -1; |
| 3792 | char path[512]; |
| 3793 | snprintf(path, sizeof(path), "%s/hack/a.sh", tmp); |
| 3794 | (void)remove(path); |
| 3795 | if (!legacy) { |
| 3796 | *after_script = |
| 3797 | k8s_inc_index(tmp, db_path) == 0 ? k8s_inc_count(db_path, processes) : -1; |
| 3798 | *route = cbm_pipeline_incremental_test_last_route(); |
| 3799 | } |
| 3800 | snprintf(path, sizeof(path), "%s/app.py", tmp); |
| 3801 | (void)remove(path); |
| 3802 | #if defined(CBM_INCREMENTAL_TEST_API) && CBM_INCREMENTAL_TEST_API |
| 3803 | if (legacy) { |
| 3804 | cbm_pipeline_incremental_test_force_legacy_partial_once(); |
| 3805 | } |
| 3806 | #endif |
| 3807 | int after = k8s_inc_index(tmp, db_path) == 0 ? k8s_inc_count(db_path, processes) : -1; |
| 3808 | *(legacy ? route : python_route) = cbm_pipeline_incremental_test_last_route(); |
| 3809 | th_rmtree(tmp); |
| 3810 | return full == 3 ? after : -1; |
| 3811 | } |
| 3812 | |
| 3813 | TEST(incremental_deleted_spawner_drops_its_process) { |
| 3814 | cbm_incremental_route_t route = CBM_INCREMENTAL_ROUTE_NONE; |
no test coverage detected