Esempio n. 1
0
int main()
{
	int ret;
	//环境初始化
	inittest();
	ret = syn_init();
	p_err(ret);
	ret = syn_rwlock_init(2);
	p_err(ret);

	//测试用例1
	ret = syn_rwlock_destroy(2);
	assert(ret == 0,"syn_rwlock_destroy Use Case 1 error");

	//测试用例2
	ret = syn_rwlock_init(2);
	p_err(ret);
	ret = syn_rwlock_destroy(64);
	assert(ret == -ERR_INVAL,"syn_rwlock_destroy Use Case 2 error");

	//测试用例3
	ret = syn_rwlock_destroy(4);
	assert(ret == -ERR_NOINIT,"syn_rwlock_destroy Use Case 3 error");

	//测试用例4
	ret = syn_rwlock_rd(2,SYN_RECV_BLOCK);
	p_err(ret);
	ret = syn_rwlock_destroy(2);
	assert(ret == -ERR_BUSY,"syn_rwlock_destroy Use Case 4 error");

	finaltest();
	return 0;
}
Esempio n. 2
0
static int synL_new( lua_State *L )
{
   synthesis_t syn;
   int num = luaL_checkint(L,1);
   syn_init( &syn );
   syn_set_frames( &syn, num );
   lua_pushsyn(L, syn);
   return 1;
}
Esempio n. 3
0
static void preprocess_only()
{
  int character;

#ifdef PASCAL /*ECN*/
  syn_init();
#endif

  if (ccom_flags & FLG_PREPROCESS)
  {   /* Selected if -E or -E -MD set */
      while ((character = pp_nextchar()) != PP_EOF) putchar(character);
  }
  else
  {   /* Selected if -M set */
      while ( (character = pp_nextchar()) != PP_EOF );
  }
}
Esempio n. 4
0
int main()
{
	int ret;
	//环境初始化
	inittest();
	ret = syn_init();
	p_err(ret);
	ret = syn_rwlock_init(2);
	p_err(ret);

	//测试用例1
	ret = syn_rwlock_wr(2,SYN_RECV_BLOCK);
	assert(ret == 0,"syn_rwlock_wr Use Case 1 error");
	ret = syn_rwlock_unlock(2);
	p_err(ret);

	//测试用例2-边界
	ret = syn_rwlock_wr(64,SYN_RECV_BLOCK);
	assert(ret == -ERR_INVAL,"syn_rwlock_wr Use Case 2 error");

	//测试用例3-错误
	ret = syn_rwlock_wr(4,SYN_RECV_BLOCK);
	assert(ret == -ERR_NOINIT,"syn_rwlock_wr Use Case 3 error");

	//测试用例4-错误
	ret = syn_rwlock_wr(2,10);
	assert(ret == -ERR_INVAL, "syn_rwlock_wr Use Case 4 error");

	//测试用例5-覆盖
	ret = syn_rwlock_wr(2,SYN_RECV_NONBLOCK);
	assert(ret == 0,"syn_rwlock_wr Use Case 5 error");

	//测试用例5-覆盖
	ret = syn_rwlock_wr(2,SYN_RECV_NONBLOCK);
	assert(ret == -ERR_BUSY,"syn_rwlock_wr Use Case 5 error");

	finaltest();
	return 0;
}
Esempio n. 5
0
static void compile_statements(void)
{ bool decls = NO;
#ifdef TARGET_IS_C40
      if (suppress_module == 1)
	{
	  cc_warn( "strings will be placed in the code segment - they may not be accessible!" );
	}
#endif
#ifndef PASCAL /*ECN*/
/* AM, Sept 91: I am inclined to think the best interface is to call    */
/* rd_topdecl(0) (1,2,3,...) until it returns NULL (or list1(s_eof))    */
/* Then all conceivable actions could be done, instead of this mess.    */
  while (!syn_eof())        /* language (even PASCAL) defines as wished */
  {
#endif
      TopDecl *d;
#ifndef TARGET_IS_HELIOS
      clock_t t0;
#endif
      phasename = "reinit";
      lex_beware_reinit();  /* preserve needed things over reinit */
      drop_local_store();   /* in case nextsym() above read #if   */
      alloc_reinit();
      lex_reinit();
      cg_reinit();          /* must be done BEFORE parsing */
#ifdef PASCAL /*ECN*/
      syn_init();           /* @@@ AM: surely is just part of rd_topdecl? */
                            /* then syn_init can be OK as usual.          */
#endif

#if !defined PASCAL /*ECN*/ && !defined TARGET_IS_HELIOS
      t0 = clock();
#endif
      phasename = "parse";
      d = rd_topdecl();
      decls |= (d != NULL);
      alloc_noteAEstoreuse();
#if !defined PASCAL /*ECN*/ && !defined TARGET_IS_HELIOS
      tmuse_front += clock() - t0;
#endif

      if (debugging(DEBUG_AETREE)) pr_topdecl(d);

#ifndef TARGET_IS_HELIOS
      t0 = clock();
#endif

      phasename = "jopcode";
      cg_topdecl(d, curlex.fl);

#ifndef TARGET_IS_HELIOS
      tmuse_back += clock() - t0;
#endif

      drop_local_store();
#ifndef PASCAL /*ECN*/
  }
  if (!decls && !(feature & FEATURE_PCC))       /* move to syn_eof()?   */
      cc_rerr(compiler_rerr_no_extern_decl);
#endif
#ifdef CPLUSPLUS
  {   TopDecl *d;
      drop_local_store();
      alloc_reinit();
      cg_reinit();
      if ((d = vg_dynamic_init()) != NULL)
      {   if (debugging(DEBUG_AETREE)) pr_topdecl(d);
          phasename = "jopcode";
          cg_topdecl(d, curlex.fl);
          drop_local_store();
          vg_ref_dynamic_init();
      }
  }
#endif
#ifdef TARGET_IS_HELIOS
  obj_makestubs();            /* tentative positioning */
#endif
}
Esempio n. 6
0
int main(int argc, char **argv){
	if(argc != 10){
	  printf("Usage: hostname port packet_loss_ratio corruption_ratio continuous_transmission simulation_runtime byte_count wireless_connection active_queue_management\n");
	  return 0;
	}
	char address[256];
	char port[6];
	memset(address, 0, sizeof(address));
	memset(port, 0, sizeof(port));
	strcpy(address, argv[1]);
	strcpy(port, argv[2]);
	if(atoi(port) > 65535){
	  printf("Port range exceeded (65535).\n");
	  return 0;
	}

	uint8_t ploss = atoi(argv[3]);
	if(ploss > 100){
	  printf("Packet loss ratio cannot exceed 100 percent.\n");
	  return 0;
	}

	uint8_t corr = atoi(argv[4]);
	if(corr > 100){
	  printf("Corruption ratio cannot exceed 100 percent.\n");
	  return 0;
	}

	struct addrinfo hints;
	memset(&hints, 0, sizeof(struct addrinfo));
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_DGRAM;

	int status;
	struct addrinfo* servinfo = NULL;
        /* Get information about all IP addresses to choose from. */
        if((status = getaddrinfo(address,port, &hints, &servinfo)) != 0){
                fprintf(stderr,"Error in getaddrinfo: %s\n", gai_strerror(status));
                exit(1);
        }

        struct addrinfo *p = servinfo;
        void* addr;
        char* ipver;

        printf("These are the addresses which were resolved:\n");
        int i = 0;
        while(p != NULL){
         if(p->ai_family == AF_INET) {
            struct sockaddr_in *ipv4 = (struct sockaddr_in *)p->ai_addr;
            addr = &(ipv4->sin_addr);
            ipver = "IPv4";
         }else{
            struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)p->ai_addr;
            addr = &(ipv6->sin6_addr);
            ipver = "IPv6";
         }
	 char ipstr[INET6_ADDRSTRLEN];
         inet_ntop(p->ai_family,addr,ipstr,sizeof(ipstr));
         printf("%i) %s: %s\n",i, ipver,ipstr);
         p = p->ai_next;
         i++;
        }

        printf("Choose one: ");
        char iface[2];
        iface[0] = getchar();
        iface[1] = '\0';
        int j = atoi(iface);
        if((iface[0]<48)||(iface[0]>57) || j >= i){
         printf("Not a destination - exiting.\n");
         exit(1);
        }

        int k;
        p = servinfo;
        for(k = 0; k < j && k < i; k++){
         if(p->ai_next != NULL)
          p = p->ai_next;
        }

	if(!set_parameters(p, ploss, corr, atoi(argv[5]), atoi(argv[6]), atoi(argv[7]), atoi(argv[8]), atoi(argv[9]))){
	  printf("Could not set network parameters.\n");
	  return -1;
	}

	char* buf = malloc(atoi(argv[7]));
	push_data_to_output_buffer(buf, atoi(argv[7]));

	if(!syn_init()){
	  printf("Could not establish connection to sleepy server.\n");
	  return -1;
	}

	loop();

	return 0;
}