Ejemplo n.º 1
0
static char *gen_fullpath(const char *prefix, char **comps)
{
	uint32_t i;
	uint32_t number_of_components;
	char *path=NULL;
	char *file=NULL;
	number_of_components=prng_next()%6;
	if(prefix)
	{
		fail_unless(!astrcat(&path, "", __func__));
		fail_unless(!astrcat(&path, prefix, __func__));
	}
	for(i=0; i<number_of_components; i++)
	{
		uint32_t choice;
		choice=prng_next()%COMP_SIZE;
		fail_unless(!astrcat(&path, "/", __func__));
		fail_unless(!astrcat(&path, comps[choice], __func__));
	}

	fail_unless((file=comp_gen())!=NULL);
	fail_unless(!astrcat(&path, "/", __func__));
	fail_unless(!astrcat(&path, file, __func__));
	free_w(&file);
	return path;
}
Ejemplo n.º 2
0
void prng_to_vlong(prng *p, vlPoint V)
{
    unsigned i;

    V[0] = VL_UNITS - 2;

    for (i = 1; i < VL_UNITS - 1; i += 1) {
        V[i] = (word16)prng_next(p);
    }
}
Ejemplo n.º 3
0
static char *comp_gen(void)
{
	char *c;
	int32_t r;
	char comp[16]="";
	r=5+(prng_next()%10);
	for(c=comp; c-comp<r; c++)
		*c=char_gen();
	*c='\0';
	return strdup_w(comp, __func__);
}
Ejemplo n.º 4
0
static char char_gen(void)
{
	char a='\0';
	uint32_t r=0;
	while(!isalnum(a))
	{
		if(!r) r=prng_next();
		a=r>>=8;
	}
	return a;
}
Ejemplo n.º 5
0
static void set_sbuf_protocol2(struct slist *slist, struct sbuf *sb,
	int with_data_files)
{
	struct blk *tail=NULL;
	struct blist *blist=slist->blist;
	if(sbuf_is_filedata(sb) || sbuf_is_vssdata(sb))
	{
		if(blist->tail) tail=blist->tail;
		build_blks(blist, prng_next()%50, with_data_files);
		if(tail)
			sb->protocol2->bstart=tail->next;
		else
			sb->protocol2->bstart=blist->head; // first one

		if(sb->protocol2->bstart)
			sb->protocol2->bend=slist->blist->tail;
	}
}