Deleting the only script requesting a URL leaves no Route behind -- a full * index never makes one without an edge; the Route a kept script requests * stays. `legacy`: through the full-load route, else closure repair. Returns * the Route count after the deletion, or -1; *route: the route taken. */
| 3832 | * stays. `legacy`: through the full-load route, else closure repair. Returns |
| 3833 | * the Route count after the deletion, or -1; *route: the route taken. */ |
| 3834 | static int incremental_caller_delete(bool legacy, cbm_incremental_route_t *route) { |
| 3835 | char tmp[256]; |
| 3836 | snprintf(tmp, sizeof(tmp), "/tmp/cbm_routegc_XXXXXX"); |
| 3837 | if (!cbm_mkdtemp(tmp)) { |
| 3838 | return -1; |
| 3839 | } |
| 3840 | write_temp_file(tmp, "hack/a.sh", "#!/bin/sh\ncurl -fsSL https://dl.example.com/a.tgz\n"); |
| 3841 | write_temp_file(tmp, "hack/b.sh", "#!/bin/sh\nwget https://dl.example.com/b.tgz\n"); |
| 3842 | char db_path[512]; |
| 3843 | snprintf(db_path, sizeof(db_path), "%s/routegc.db", tmp); |
| 3844 | static const char routes[] = "SELECT COUNT(*) FROM nodes WHERE label='Route'"; |
| 3845 | int full = k8s_inc_index(tmp, db_path) == 0 ? k8s_inc_count(db_path, routes) : -1; |
| 3846 | char path[512]; |
| 3847 | snprintf(path, sizeof(path), "%s/hack/a.sh", tmp); |
| 3848 | (void)remove(path); |
| 3849 | #if defined(CBM_INCREMENTAL_TEST_API) && CBM_INCREMENTAL_TEST_API |
| 3850 | if (legacy) { |
| 3851 | cbm_pipeline_incremental_test_force_legacy_partial_once(); |
| 3852 | } |
| 3853 | #endif |
| 3854 | int after = k8s_inc_index(tmp, db_path) == 0 ? k8s_inc_count(db_path, routes) : -1; |
| 3855 | *route = cbm_pipeline_incremental_test_last_route(); |
| 3856 | th_rmtree(tmp); |
| 3857 | return full == 2 ? after : -1; |
| 3858 | } |
| 3859 | |
| 3860 | TEST(incremental_deleted_caller_drops_its_route) { |
| 3861 | cbm_incremental_route_t route = CBM_INCREMENTAL_ROUTE_NONE; |
no test coverage detected