Exemplo n.º 1
0
/*
 * get command line flags, initialize keywords & traps.
 * get values from environment.
 * set $pid, $cflag, $*
 * fabricate bootstrap code and start it (*=(argv);. /usr/lib/rcmain $*)
 * start interpreting code
 */
int
main(int argc, char *argv[])
{
	code bootstrap[32];
	char num[12], *rcmain;
	int i;
	
	/* needed for rcmain later */
	putenv("PLAN9", unsharp("#9"));
	argc = getflags(argc, argv, "ftjSsrdiIlxepvVc:1m:1[command]", 1);
	if(argc==-1)
		usage("[file [arg ...]]");
	if(argv[0][0]=='-')
		flag['l'] = flagset;
	if(flag['I'])
		flag['i'] = 0;
	else if(flag['i']==0 && argc==1 && Isatty(0)) flag['i'] = flagset;
	rcmain = flag['m'] ? flag['m'][0] : Rcmain();
	err = openfd(2);
	kinit();
	Trapinit();
	Vinit();
	inttoascii(num, mypid = getpid());
	pathinit();
	setvar("pid", newword(num, (word *)0));
	setvar("cflag", flag['c']?newword(flag['c'][0], (word *)0)
				:(word *)0);
	setvar("rcname", newword(argv[0], (word *)0));
	i = 0;
	bootstrap[i++].i = 1;
	bootstrap[i++].f = Xmark;
	bootstrap[i++].f = Xword;
	bootstrap[i++].s="*";
	bootstrap[i++].f = Xassign;
	bootstrap[i++].f = Xmark;
	bootstrap[i++].f = Xmark;
	bootstrap[i++].f = Xword;
	bootstrap[i++].s="*";
	bootstrap[i++].f = Xdol;
	bootstrap[i++].f = Xword;
	bootstrap[i++].s = rcmain;
	bootstrap[i++].f = Xword;
	bootstrap[i++].s=".";
	bootstrap[i++].f = Xsimple;
	bootstrap[i++].f = Xexit;
	bootstrap[i].i = 0;
	start(bootstrap, 1, (var *)0);
	/* prime bootstrap argv */
	pushlist();
	argv0 = strdup(argv[0]);
	for(i = argc-1;i!=0;--i) pushword(argv[i]);
	for(;;){
		if(flag['r'])
			pfnc(err, runq);
		runq->pc++;
		(*runq->code[runq->pc-1].f)();
		if(ntrap)
			dotrap();
	}
}
Exemplo n.º 2
0
END_TEST

/* Negative Voice press, aftertouch and release function tests.  */
START_TEST (test_fz_voice_press_neg)
{
  srand (time (0));

  int_t (*pfnc) (voice_t *, real_t, real_t) = fz_voice_press;
  int_t (*afnc) (voice_t *, real_t) = fz_voice_aftertouch;
  int_t (*rfnc) (voice_t *) = fz_voice_release;
  real_t freq = -(real_t) (rand () % 10000);
  real_t velo = -((real_t) rand ()) / RAND_MAX;
  real_t pres = -((real_t) rand ()) / RAND_MAX;

  /* Press bad values.  */
  ck_assert (pfnc (NULL, 1, 1) == EINVAL);
  ck_assert (fz_voice_pressed (voice) == FALSE);
  ck_assert (pfnc (voice, 0, 1) == EINVAL);
  ck_assert (fz_voice_pressed (voice) == FALSE);
  ck_assert (pfnc (voice, freq, 1) == EINVAL);
  ck_assert (fz_voice_pressed (voice) == FALSE);
  ck_assert (pfnc (voice, 1, 0) == EINVAL);
  ck_assert (fz_voice_pressed (voice) == FALSE);
  ck_assert (pfnc (voice, 1, velo) == EINVAL);
  ck_assert (fz_voice_pressed (voice) == FALSE);

  pfnc (voice, 1, 1);
  ck_assert (fz_voice_pressed (voice) == TRUE);
  ck_assert (pfnc (voice, 1, 1) == EINVAL); /* Already pressed.  */

  /* Touch bad values,  */
  ck_assert (afnc (NULL, 1) == EINVAL);
  ck_assert (afnc (voice, 0) == EINVAL);
  ck_assert (afnc (voice, pres) == EINVAL);

  /* Release bad values.  */
  ck_assert (rfnc (NULL) == EINVAL);
  rfnc (voice);
  ck_assert (fz_voice_pressed (voice) == FALSE);
  ck_assert (rfnc (voice) == EINVAL); /* Already released.  */
  ck_assert (afnc (voice, 1) == EINVAL); /* Touch released voice.  */
}