extern OBJ _AUserAndGroup_Ahc_Agetgroups(OBJ x1) /* hc_getgroups */ {OBJ r; int gasize; free_some(x1,1); gasize=getgroups(0,NULL); if(gasize<0){ return_unix_failure(errno); } if(gasize==0){ r=alloc_array(0); } else{ gid_t *gidarray; int i; gidarray=(gid_t*)malloc_aux(sizeof(gid_t)*gasize); if(getgroups(gasize,gidarray)!=gasize){ return_unix_failure(errno); } r=alloc_array(gasize); for(i=0;i<gasize;i++){ make_groupid(gidarray[i],data_array(r)[i]); } free_aux(gidarray); } return_okay(r); }
static void test_aux_data_added_nvpairs_are_returned_by_foreach_in_order(void) { LogTransportAuxData *aux = construct_aux_with_some_data(); log_transport_aux_data_add_nv_pair(aux, "super", "lativus"); assert_concatenated_nvpairs(aux, "foo=bar\nsuper=lativus\n"); free_aux(aux); }
static void test_aux_data_reinit_returns_aux_into_initial_state_without_leaks(void) { LogTransportAuxData *aux = construct_aux_with_some_data(); log_transport_aux_data_reinit(aux); assert_null(aux->peer_addr, "aux->peer_addr is not NULL after reinit"); free_aux(aux); }
static void test_aux_data_copy_creates_an_identical_copy(void) { LogTransportAuxData *aux = construct_aux_with_some_data(); LogTransportAuxData aux_copy; gchar *orig, *copy; log_transport_aux_data_copy(&aux_copy, aux); orig = _concat_nvpairs(aux); copy = _concat_nvpairs(&aux_copy); assert_string(orig, copy, "copy incorrectly copied aux->nvpairs"); g_free(orig); g_free(copy); log_transport_aux_data_destroy(&aux_copy); free_aux(aux); }
static void test_aux_data_copy_separates_the_copies(void) { LogTransportAuxData *aux = construct_aux_with_some_data(); LogTransportAuxData aux_copy; gchar *orig, *copy; log_transport_aux_data_copy(&aux_copy, aux); log_transport_aux_data_add_nv_pair(aux, "super", "lativus"); orig = _concat_nvpairs(aux); copy = _concat_nvpairs(&aux_copy); assert_false(strcmp(orig, copy) == 0, "copy incorrectly copied aux->nvpairs as change to one of them affected the other, orig=%s, copy=%s", orig, copy); g_free(orig); g_free(copy); log_transport_aux_data_destroy(&aux_copy); free_aux(aux); }