Example #1
0
int main(void)
{
	bool ret = true;

	talloc_disable_null_tracking();
	talloc_enable_null_tracking();

	ret &= test_ref1();
	ret &= test_ref2();
	ret &= test_ref3();
	ret &= test_ref4();
	ret &= test_unlink1(); 
	ret &= test_misc();
	ret &= test_realloc();
	ret &= test_realloc_child(); 
	ret &= test_steal(); 
	ret &= test_move(); 
	ret &= test_unref_reparent();
	ret &= test_realloc_fn(); 
	ret &= test_type();
	ret &= test_lifeless(); 
	ret &= test_loop();
	ret &= test_free_parent_deny_child(); 
	ret &= test_talloc_ptrtype();

	if (ret) {
		ret &= test_speed();
	}
	ret &= test_autofree();

	if (!ret)
		return -1;
	return 0;
}
Example #2
0
void test_search(void)
{
	init();
	test_move("rnb1kbnr/pppppppp/8/5q2/4P3/8/PPPP1PPP/RNBQKBNR", WHITE,
			  "e4f5");
	
}
Example #3
0
int main() {
    test_it();
    test_non_pod();

    test_move();
    return 0;
}
Example #4
0
 void run ()
 {
     test_bad_json ();
     test_edge_cases ();
     test_copy ();
     test_move ();
 }
Example #5
0
/******************************************************************************
* Calls the Roomba interface function given some serialized function call
******************************************************************************/
void deserialize(uint8_t* function)
{
	switch(function[0])
	{
	case INITIALIZE_ROOMBA:
		initialize_roomba();
		break;
	case SET_MODE:
		set_mode((roomba_mode_t)(function[1] - ASCII_OFFSET));
		break;
	case START_CLEAN:
		start_clean((clean_mode_t)(function[1] - ASCII_OFFSET));
		break;
	case SEND_DOCK:
		send_dock();
		break;
	case SET_WHEEL_SPEEDS:
	{
		/* high byte right, low byte right, high byte left, low byte left */
		int16_t left, right;
		right = (function[1] << 8) & function[2];
		left = (function[3] << 8) & function[4];
		set_wheel_speeds(right, left);
	}
    break;
	case TEST_MOVE:
		test_move();
		break;
    case PLAY_SONG:
        play_song(function[1] - ASCII_OFFSET);
        break;
	}
}
Example #6
0
int Game::move_piece(int x, int y) {
	if (test_move(x, y) == 0)
		return 1;
	Play p(select_pawn, pawn[select_pawn].pos[0], pawn[select_pawn].pos[1], x, y);
	history.push_back(p);
	pawn[select_pawn].move(x, y);
	return 0;
}
TEST(gogame_move_check, single_piece_full_liberty_corner) {
    uint8_t board_size = 3;
    GoGame test(board_size);

    GoMove test_move(test.get_board(), XYCoordinate(0, 0));

    EXPECT_EQ(2, test_move.check_move(0));
}
TEST(gogame_move_check, move_already_calculated) {
    uint8_t board_size = 3;
    GoGame test(board_size);

    GoMove test_move(test.get_board(), XYCoordinate(0, 0));
    test_move.check_move(0);

    EXPECT_EQ(-1, test_move.check_move(0));
}
int main()
{
    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
    const int N = sizeof(rng)/sizeof(rng[0]);
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j)
            for (int k = 0; k < N; ++k)
                testN(rng[i], rng[j], rng[k]);
    testNI(1500, 2000, 1000);
    test_move();
}
Example #10
0
int main() {
    try {
        test_move();
        
        u_cleanup();
    } catch (const std::exception& e) {
        std::cout << e.what() << std::endl;
        return 1;
    }
    return 0;
}
Example #11
0
 void run () override
 {
     test_bool ();
     test_bad_json ();
     test_edge_cases ();
     test_copy ();
     test_move ();
     test_comparisons ();
     test_compact ();
     test_nest_limits ();
 }
TEST(gogame_move_check, single_piece_surrounded) {
    uint8_t board_size = 3;
    GoBoard test_board(board_size);
    test_board.board[0][1] = get_mask(1);
    test_board.board[2][1] = get_mask(1);
    test_board.board[1][0] = get_mask(1);
    test_board.board[1][2] = get_mask(1);

    GoMove test_move(test_board, XYCoordinate(1, 1));

    EXPECT_EQ(0, test_move.check_move(0));
}
Example #13
0
	void test_bitboard()
	{
		test_bit_count();
		test_get_lowest_bit();
		test_floor_log2();
		test_simple_move_mask();
		test_move();
		test_bit_mask();		
		test_cached_king_move_mask();
		test_cached_knight_move_mask();
		test_cached_rook_move_mask();
		test_cached_bishop_move_mask();
	}
Example #14
0
int main (int argc, char *argv[])
{
  bool result= true;

  result = result && test_equality_bool(true, test_new_piece(), "new_piece");
  result = result && test_equality_bool(true, test_intersect(), "intersect");
  result = result && test_equality_bool(true, test_move(), "move");
  result = result && test_equality_bool(true, test_copy(), "copy");

  if (result){
    printf("Youpi !\n");
    return EXIT_SUCCESS;
  }else{
    return EXIT_FAILURE;
  }
}
Example #15
0
int main(int argc, char *argv[])
{
        (void) argc;
        (void) argv;

        Seq_T segments = Seq_new(0);

        test_add(segments);

        test_get_seg();

        test_get_word(segments);

        test_move();

        test_clear();
}
Example #16
0
int main()
{
	adam_init();

	test_move();
	test_return();
	test_const();
	test_monitor();
	test_packed(); 
	test_sparse();
	test_arrayops();
	test_instanceops();
	test_invoke();

	adam_finalize();
	
	return 0;
}
Example #17
0
static int
run_test (int /*unused*/, char* /*unused*/ [])
{
    test_identity ();

#if !defined _RWSTD_NO_RVALUE_REFERENCES

    test_forward ();
    test_move ();

#else // no rvalue references

    rw_warn (0, 0, __LINE__,
             "No compiler support for rvalue references; tests disabled.");

#endif   // !defined _RWSTD_NO_RVALUE_REFERENCES

    return 0;
}
Example #18
0
        void main()
        {
            std::cout << "[:: Test 1: Call with no side effects. ::]" << std::endl;
            test_simple();

            std::cout << "[:: Test 2: Call with side effects. ::]" << std::endl;
            test_side_effects();

            std::cout << "[:: Test 3: Copy stuff. ::]" << std::endl;
            test_copy();

            std::cout << "[:: Test 4: Copy ctor stuff. ::]" << std::endl;
            test_copy_ctor();

            std::cout << "[:: Test 5: Move stuff. ::]" << std::endl;
            test_move();

            std::cout << "[:: Test 6: Move ctor stuff. ::]" << std::endl;
            test_move_ctor();
        }
int main(int argc, char** argv)
{
    ros::init(argc, argv, "my_interesting_moves_test");
    ros::NodeHandle nh;

    // initialize an object for class my_interesting_moves
    MyInterestingMoves test_move(&nh);

    // test move 1
    ROS_INFO_STREAM(endl << endl << endl << "move 1 testing...");
    test_move.all_joint_1_origin();

    // test move 2
    ROS_INFO_STREAM(endl << endl << endl << "move 2 testing...");
    test_move.all_joint_2_upper_limit();

    // test move 3
    ROS_INFO_STREAM(endl << endl << endl << "move 3 testing...");
    test_move.all_joint_3_lower_limit();
}
Example #20
0
int main(int argc, char *argv[])
{
    bool result = true;
    piece no_piece = NULL;

    printf("result of test error\n");
    test_equality_int(0, 1, "error test_equality_int ");
    test_equality_bool(true, false, "error test_equality_bool ");
    test_failure_piece(no_piece);
    printf("----------------------------------------------------------\n");
    delete_piece(no_piece);
    result = result && test_equality_bool(true, test_new_piece(), "new_piece");
    result = result && test_equality_bool(true, test_intersect(), "intersect");
    result = result && test_equality_bool(true, test_move(), "move");
    result = result && test_equality_bool(true, test_copy(), "copy");


    if (result) {
        printf("Youpi !\n");
        return EXIT_SUCCESS;
    } else
        return EXIT_FAILURE;
}
Example #21
0
DEF_TEST(TArray, reporter) {
    TestTSet_basic<true>(reporter);
    TestTSet_basic<false>(reporter);
    test_swap(reporter);

    test_copy_ctor(reporter, SkTArray<sk_sp<SkRefCnt>, false>());
    test_copy_ctor(reporter, SkTArray<sk_sp<SkRefCnt>,  true>());
    test_copy_ctor(reporter, SkSTArray< 1, sk_sp<SkRefCnt>, false>());
    test_copy_ctor(reporter, SkSTArray< 1, sk_sp<SkRefCnt>,  true>());
    test_copy_ctor(reporter, SkSTArray<10, sk_sp<SkRefCnt>, false>());
    test_copy_ctor(reporter, SkSTArray<10, sk_sp<SkRefCnt>,  true>());

    test_move(reporter);

    test_unnecessary_alloc(reporter);

    test_self_assignment(reporter);

    test_reserve<SkTArray<int>>(reporter);
    test_reserve<SkSTArray<1, int>>(reporter);
    test_reserve<SkSTArray<2, int>>(reporter);
    test_reserve<SkSTArray<16, int>>(reporter);
}
Example #22
0
const char* game(int user)
{
	int i, j, k, move, win = 0;
	for_ij b[i][j] = 0;
 
	printf("Board postions are numbered so:\n1 2 3\n4 5 6\n7 8 9\n");
	printf("You have O, I have X.\n\n");
	for (k = 0; k < 9; k++, user = !user) {
		while(user) {
			printf("your move: ");
			if (!scanf("%d", &move)) {
				scanf("%*s");
				continue;
			}
			if (--move < 0 || move >= 9) continue;
			if (b[i = move / 3][j = move % 3]) continue;
 
			b[i][j] = 1;
			break;
		}
		if (!user) {
			if (!k) { /* randomize if computer opens, less boring */
				best_i = rand() % 3;
				best_j = rand() % 3;
			} else
				test_move(-1, 0);
 
			b[best_i][best_j] = -1;
			printf("My move: %d\n", best_i * 3 + best_j + 1);
		}
 
		showboard();
		if ((win = check_winner())) 
			return win == 1 ? "You win.\n\n": "I win.\n\n";
	}
	return "A draw.\n\n";
}
Example #23
0
int test_move(int val, int depth)
{
	int i, j, score;
	int best = -1, changed = 0;
 
	if ((score = check_winner())) return (score == val) ? 1 : -1;
 
	for_ij {
		if (b[i][j]) continue;
 
		changed = b[i][j] = val;
		score = -test_move(-val, depth + 1);
		b[i][j] = 0;
 
		if (score <= best) continue;
		if (!depth) {
			best_i = i;
			best_j = j;
		}
		best = score;
	}
 
	return changed ? best : 0;
}
Example #24
0
bool torture_local_talloc(struct torture_context *tctx)
{
	bool ret = true;

	setlinebuf(stdout);

	talloc_disable_null_tracking();
	talloc_enable_null_tracking();

	ret &= test_ref1();
	ret &= test_ref2();
	ret &= test_ref3();
	ret &= test_ref4();
	ret &= test_unlink1(); 
	ret &= test_misc();
	ret &= test_realloc();
	ret &= test_realloc_child(); 
	ret &= test_steal(); 
	ret &= test_move(); 
	ret &= test_unref_reparent();
	ret &= test_realloc_fn(); 
	ret &= test_type();
	ret &= test_lifeless(); 
	ret &= test_loop();
	ret &= test_free_parent_deny_child(); 
	ret &= test_talloc_ptrtype();
	ret &= test_talloc_free_in_destructor();
	ret &= test_pool();

	if (ret) {
		ret &= test_speed();
	}
	ret &= test_autofree();

	return ret;
}
Example #25
0
int		second_choices(t_player *player, char **map, int left, int top)
{
  if (top == 0 && left != 0)
    {
      if (test_move(player, map, player->x + left, player->y + 1)
	  || test_move(player, map, player->x + left, player->y - 1))
	return 1;
    }
  else if (top != 0 && left == 0)
    {
      if (test_move(player, map, player->x + 1, player->y + top)
	  || test_move(player, map, player->x - 1, player->y + top))
	return 1;
    }
  else
    {
      if (test_move(player, map, player->x, player->y + top)
	  || test_move(player, map, player->x + left, player->y))
	return 1;
    }
  return 0;
}
Example #26
0
void zeromq_thread() {
	{
		void* objectContext = zmq_ctx_new();
		void* objectSocket = zmq_socket(objectContext, ZMQ_PAIR);
		
		{
			char charZeromq[1024] = { };
			
			sprintf(charZeromq, "tcp://localhost:%d", main_intZeromq);
			
			if (zmq_connect(objectSocket, charZeromq) == -1) {
				printf("zeromq: %s\n", zmq_strerror(zmq_errno()));
			}
		}
		
		{
			zeromq_objectSocket = objectSocket;
		}
		
		{
			void* objectMonitor = zmq_socket(objectContext, ZMQ_PAIR);
			
			{
				if (zmq_socket_monitor(objectSocket, "inproc://minichess-zeromq-monitor", ZMQ_EVENT_ALL) == -1) {
					printf("zeromq: %s\n", zmq_strerror(zmq_errno()));
				}
				
				if (zmq_connect(objectMonitor, "inproc://minichess-zeromq-monitor") == -1) {
					printf("zeromq: %s\n", zmq_strerror(zmq_errno()));
				}
			}
			
			{
				do {
					int intEventspecifier = 0;
					int intEventvalue = 0;
					char charEventaddress[256] = { };
					
					#if (ZMQ_VERSION_MAJOR == 3)
						{
							zmq_msg_t objectMessage = { };
							
							zmq_msg_init(&objectMessage);
							
							if (zmq_recvmsg(objectMonitor, &objectMessage, 0) == -1) {
								printf("zeromq: %s\n", zmq_strerror(zmq_errno()));
							}
							
							zmq_event_t objectEvent = { };
							
							memcpy(&objectEvent, zmq_msg_data(&objectMessage), sizeof(objectEvent));
							
							intEventspecifier = objectEvent.event;
							intEventvalue = 0
							charEventaddress[0] = '\0';
							
							zmq_msg_close(&objectMessage);
						}
						
					#elif (ZMQ_VERSION_MAJOR == 4)
						{
							zmq_msg_t objectMessage = { };
							
							zmq_msg_init(&objectMessage);
							
							if (zmq_recvmsg(objectMonitor, &objectMessage, 0) == -1) {
								printf("zeromq: %s\n", zmq_strerror(zmq_errno()));
							}
							
							uint8_t* intData = (uint8_t*) (zmq_msg_data(&objectMessage));
							
							intEventspecifier = *(uint16_t*) (intData + 0);
							intEventvalue = *(uint32_t*) (intData + 2);
							
							zmq_msg_close(&objectMessage);
						}
						
						{
							zmq_msg_t objectMessage = { };
							
							zmq_msg_init(&objectMessage);
							
							if (zmq_recvmsg(objectMonitor, &objectMessage, 0) == -1) {
								printf("zeromq: %s\n", zmq_strerror(zmq_errno()));
							}
							
							charEventaddress[0] = '\0';
							
							zmq_msg_close(&objectMessage);
						}
						
					#endif
					
					{
						if (intEventspecifier == ZMQ_EVENT_CONNECTED) {
							{
								zeromq_boolConnected = true;
								
								webserver_broadcast("zeromq_status", NULL);
							}
							
							{
								cJSON* objectOut = cJSON_CreateObject();
								cJSON* objectIn = NULL;
								
								{
									cJSON_AddStringToObject(objectOut, "strFunction", "ping");
								}
								
								{
									zeromq_send(objectOut);
									
									objectIn = zeromq_recv();
								}
								
								{
									strcpy(zeromq_charClient, cJSON_GetObjectItem(objectIn, "strOut")->valuestring);
									
									webserver_broadcast("zeromq_name", NULL);
								}
								
								cJSON_Delete(objectOut);
								cJSON_Delete(objectIn);
							}
							
							{
								printf("zeromq: connected to %s\n", zeromq_charClient);
							}
							
						} else if (intEventspecifier == ZMQ_EVENT_DISCONNECTED) {
							{
								zeromq_boolConnected = false;
								
								webserver_broadcast("zeromq_status", NULL);
							}
							
							{
								printf("zeromq: disconnected from %s\n", zeromq_charClient);
							}
							
						}
					}
					
					{
						if (intEventspecifier == ZMQ_EVENT_CONNECTED) {
							int intTest = 0;
							
							if (intTest > 0) {
								setbuf(stdout, NULL);
							}
							
							if (intTest > 0) {
								printf("test_board: ");
								printf("%d\n", test_board());
							}
							
							if (intTest > 1) {
								printf("test_winner: ");
								printf("%d\n", test_winner());
							}
							
							if (intTest > 2) {
								printf("test_isValid: ");
								printf("%d\n", test_isValid());
							}
							
							if (intTest > 3) {
								printf("test_isEnemy: ");
								printf("%d\n", test_isEnemy());
							}
							
							if (intTest > 4) {
								printf("test_isOwn: ");
								printf("%d\n", test_isOwn());
							}
							
							if (intTest > 5) {
								printf("test_isNothing: ");
								printf("%d\n", test_isNothing());
							}
							
							if (intTest > 6) {
								printf("test_eval: ");
								printf("%d\n", test_eval());
							}
							
							if (intTest > 7) {
								printf("test_moves: ");
								printf("%d\n", test_moves());
							}
							
							if (intTest > 8) {
								printf("test_move: ");
								printf("%d\n", test_move());
							}
							
							if (intTest > 9) {
								printf("test_undo: ");
								printf("%d\n", test_undo());
							}
							
							if (intTest > 10) {
								printf("test_movesShuffled: ");
								printf("%d\n", test_movesShuffled());
							}
							
							if (intTest > 11) {
								printf("test_movesEvaluated: ");
								printf("%d\n", test_movesEvaluated());
							}
							
							if (intTest > 12) {
								printf("test_moveRandom: ");
								printf("%d\n", test_moveRandom());
							}
							
							if (intTest > 13) {
								printf("test_moveGreedy: ");
								printf("%d\n", test_moveGreedy());
							}
							
							if (intTest > 14) {
								printf("test_moveNegamax: ");
								printf("%d\n", test_moveNegamax());
							}
							
							if (intTest > 15) {
								printf("test_moveAlphabeta: ");
								printf("%d\n", test_moveAlphabeta());
							}
						}
					}
				} while (pthread_mutex_trylock(&zeromq_objectRunning) != 0);
				
				pthread_mutex_unlock(&zeromq_objectRunning);
			}
			
			zmq_close(objectMonitor);
		}
		
		zmq_close(objectSocket);
		zmq_ctx_destroy(objectContext);
	}
}
Example #27
0
 void run ()
 {
     testBadJson ();
     test_copy ();
     test_move ();
 }
Example #28
0
/* Start riding, with the given monster */
boolean
mount_steed(struct monst * mtmp,        /* The animal */
            boolean force)
{   /* Quietly force this animal */
    struct obj *otmp;
    const struct permonst *ptr;

    /* Sanity checks */
    if (u.usteed) {
        pline("You are already riding %s.", mon_nam(u.usteed));
        return FALSE;
    }

    /* Is the player in the right form? */
    if (Hallucination && !force) {
        pline("Maybe you should find a designated driver.");
        return FALSE;
    }
    /* While riding Wounded_legs refers to the steed's, not the hero's legs.
       That opens up a potential abuse where the player can mount a steed, then
       dismount immediately to heal leg damage, because leg damage is always
       healed upon dismount (Wounded_legs context switch). By preventing a hero
       with Wounded_legs from mounting a steed, the potential for abuse is
       minimized, if not eliminated altogether. */
    if (Wounded_legs) {
        pline("Your %s are in no shape for riding.",
              makeplural(body_part(LEG)));
        if (force && wizard && yn("Heal your legs?") == 'y')
            LWounded_legs = RWounded_legs = 0;
        else
            return FALSE;
    }

    if (Upolyd &&
            (!humanoid(youmonst.data) || verysmall(youmonst.data) ||
             bigmonst(youmonst.data) || slithy(youmonst.data))) {
        pline("You won't fit on a saddle.");
        return FALSE;
    }
    if (!force && (near_capacity() > SLT_ENCUMBER)) {
        pline("You can't do that while carrying so much stuff.");
        return FALSE;
    }

    /* Can the player reach and see the monster? */
    if (!mtmp ||
            (!force &&
             ((Blind && !Blind_telepat) || mtmp->mundetected ||
              mtmp->m_ap_type == M_AP_FURNITURE ||
              mtmp->m_ap_type == M_AP_OBJECT))) {
        pline("I see nobody there.");
        return FALSE;
    }

    struct test_move_cache cache;
    init_test_move_cache(&cache);

    if (Engulfed || u.ustuck || u.utrap || Punished ||
            !test_move(u.ux, u.uy, mtmp->mx - u.ux, mtmp->my - u.uy, 0,
                       TEST_MOVE, &cache)) {
        if (Punished || !(Engulfed || u.ustuck || u.utrap))
            pline("You are unable to swing your %s over.", body_part(LEG));
        else
            pline("You are stuck here for now.");
        return FALSE;
    }

    /* Is this a valid monster? */
    otmp = which_armor(mtmp, os_saddle);
    if (!otmp) {
        pline("%s is not saddled.", Monnam(mtmp));
        return FALSE;
    }
    ptr = mtmp->data;
    if (touch_petrifies(ptr) && !Stone_resistance) {
        pline("You touch %s.", mon_nam(mtmp));
        instapetrify(killer_msg(STONING,
                                msgcat("attempting to ride ", an(mtmp->data->mname))));
    }
    if (!mtmp->mtame || mtmp->isminion) {
        pline("I think %s would mind.", mon_nam(mtmp));
        return FALSE;
    }
    if (mtmp->mtrapped) {
        struct trap *t = t_at(level, mtmp->mx, mtmp->my);

        pline("You can't mount %s while %s's trapped in %s.", mon_nam(mtmp),
              mhe(mtmp), t ? an(trapexplain[t->ttyp - 1]) : "ice");
        return FALSE;
    }

    if (!force && !Role_if(PM_KNIGHT) && !(--mtmp->mtame)) {
        /* no longer tame */
        newsym(mtmp->mx, mtmp->my);
        pline("%s resists%s!", Monnam(mtmp),
              mtmp->mleashed ? " and its leash comes off" : "");
        if (mtmp->mleashed)
            m_unleash(mtmp, FALSE);
        return FALSE;
    }
    if (!force && Underwater && !is_swimmer(ptr)) {
        pline("You can't ride that creature while under water.");
        return FALSE;
    }
    if (!can_saddle(mtmp) || !can_ride(mtmp)) {
        pline("You can't ride such a creature.");
        return 0;
    }

    /* Is the player impaired? */
    if (!force && !is_floater(ptr) && !is_flyer(ptr) && Levitation &&
            !Lev_at_will) {
        pline("You cannot reach %s.", mon_nam(mtmp));
        return FALSE;
    }
    if (!force && uarm && is_metallic(uarm) && greatest_erosion(uarm)) {
        pline("Your %s armor is too stiff to be able to mount %s.",
              uarm->oeroded ? "rusty" : "corroded", mon_nam(mtmp));
        return FALSE;
    }
    if (!force &&
            (Confusion || Fumbling || Glib || Wounded_legs || otmp->cursed ||
             ((u.ulevel + mtmp->mtame < rnd(MAXULEV / 2 + 5)) &&
              (!Role_if(PM_KNIGHT))))) {
        if (Levitation) {
            pline("%s slips away from you.", Monnam(mtmp));
            return FALSE;
        }
        pline("You slip while trying to get on %s.", mon_nam(mtmp));

        const char *buf = msgcat(
                              "slipped while mounting ",
                              /* "a saddled mumak" or "a saddled pony called Dobbin" */
                              x_monnam(mtmp, ARTICLE_A, NULL,
                                       SUPPRESS_IT | SUPPRESS_INVISIBLE |
                                       SUPPRESS_HALLUCINATION, TRUE));
        losehp(rn1(5, 10), buf);
        return FALSE;
    }

    /* Success */
    maybewakesteed(mtmp);
    if (!force) {
        if (Levitation && !is_floater(ptr) && !is_flyer(ptr))
            /* Must have Lev_at_will at this point */
            pline("%s magically floats up!", Monnam(mtmp));
        pline("You mount %s.", mon_nam(mtmp));
    }
    /* setuwep handles polearms differently when you're mounted */
    if (uwep && is_pole(uwep))
        u.bashmsg = TRUE;
    u.usteed = mtmp;
    remove_monster(level, mtmp->mx, mtmp->my);
    teleds(mtmp->mx, mtmp->my, TRUE);
    return TRUE;
}
Example #29
0
static int proc_args(int argc, char *argv[])
{
	unsigned short mode, delay, x, y, size, initial_x, initial_y, final_x, final_y, horizontal, time;
	unsigned long color;
	short distance;

	if (strncmp(argv[1], "init", 4) == 0)
	{

		if (argc != 4)
		{
			printf("wrong no of arguments for test_init()\n");
			return 1;
		}

		if ((mode = (unsigned short) parse_long(argv[2], 16)) == LONG_MAX) return 1;
		if ((delay = (unsigned short) parse_long(argv[3], 10)) == LONG_MAX) return 1;

		printf("test_init(0x%x, %d)\n", mode, delay);

		test_init(mode, delay);

		return 0;
	}
	else if (strncmp(argv[1], "square", 6) == 0)
	{
		if (argc != 6)
		{
			printf("wrong no of arguments for test_square()\n");
			return 1;
		}

		if ((x = (unsigned short) parse_long(argv[2], 10)) == LONG_MAX) return 1;
		if ((y = (unsigned short) parse_long(argv[3], 10)) == LONG_MAX) return 1;
		if ((size = (unsigned short) parse_long(argv[4], 10)) == LONG_MAX) return 1;
		if ((color = (unsigned long) parse_long(argv[5], 10)) == LONG_MAX) return 1;

		printf("test_square(%d, %d, %d, %d)\n", x, y, size, color);

		return test_square(x, y, size, color);
	}
	else if (strncmp(argv[1], "line", 4) == 0)
	{
		if (argc != 7)
		{
			printf("wrong no of arguments for test_line()\n");
			return 1;
		}

		if ((initial_x = (unsigned short) parse_long(argv[2], 10)) == LONG_MAX) return 1;
		if ((initial_y = (unsigned short) parse_long(argv[3], 10)) == LONG_MAX) return 1;
		if ((final_x = (unsigned short) parse_long(argv[4], 10)) == LONG_MAX) return 1;
		if ((final_y = (unsigned short) parse_long(argv[5], 10)) == LONG_MAX) return 1;
		if ((color = (unsigned long) parse_long(argv[6], 10)) == LONG_MAX) return 1;

		printf("test_linee(%d, %d, %d, %d, %d)\n", initial_x, initial_y, final_x, final_y, color);

		return test_line(initial_x, initial_y, final_x, final_y, color);
	}
	else if (strncmp(argv[1], "xpm", 3) == 0)
	{
		if (argc != 5)
		{
			printf("wrong no of arguments for test_xpm()\n");
			return 1;
		}

		if ((initial_x = (unsigned short) parse_long(argv[2], 10)) == LONG_MAX) return 1;
		if ((initial_y = (unsigned short) parse_long(argv[3], 10)) == LONG_MAX) return 1;

		if (strncmp(argv[4], "pic1", 4) == 0)
		{
			printf("test_xpm(%d, %d, %s)\n", initial_x, initial_y, "pic1");

			return test_xpm(initial_x, initial_y, pic1);
		}
		else if (strncmp(argv[4], "pic2", 4) == 0)
		{
			printf("test_xpm(%d, %d, %s)\n", initial_x, initial_y, "pic2");

			return test_xpm(initial_x, initial_y, pic2);
		}
		else if (strncmp(argv[4], "cross", 5) == 0)
		{
			printf("test_xpm(%d, %d, %s)\n", initial_x, initial_y, "cross");

			return test_xpm(initial_x, initial_y, cross);
		}
		else if (strncmp(argv[4], "pic3", 4) == 0)
		{
			printf("test_xpm(%d, %d, %s)\n", initial_x, initial_y, "pic3");

			return test_xpm(initial_x, initial_y, pic3);
		}
		else if (strncmp(argv[4], "penguin", 7) == 0)
		{
			printf("test_xpm(%d, %d, %s)\n", initial_x, initial_y, "penguin");

			return test_xpm(initial_x, initial_y, penguin);
		}
	}
	else if (strncmp(argv[1], "move", 4) == 0)
	{
		if (argc != 8)
		{
			printf("wrong no of arguments for test_move()\n");
			return 1;
		}

		if ((initial_x = (unsigned short) parse_long(argv[2], 10)) == LONG_MAX) return 1;
		if ((initial_y = (unsigned short) parse_long(argv[3], 10)) == LONG_MAX) return 1;
		if ((horizontal = (unsigned short) parse_long(argv[5], 10)) == LONG_MAX) return 1;
		if ((distance = (short) parse_long(argv[6], 10)) == LONG_MAX) return 1;
		if ((time = (unsigned short) parse_long(argv[7], 10)) == LONG_MAX) return 1;

		if (strncmp(argv[4], "pic1", 4) == 0)
		{
			printf("test_move(%d, %d, %s, %d, %d, %d)\n", initial_x, initial_y, "pic1", horizontal, distance, time);

			return test_move(initial_x, initial_y, pic1, horizontal, distance, time);
		}
		else if (strncmp(argv[4], "pic2", 4) == 0)
		{
			printf("test_move(%d, %d, %s, %d, %d, %d)\n", initial_x, initial_y, "pic2", horizontal, distance, time);

			return test_move(initial_x, initial_y, pic2, horizontal, distance, time);
		}
		else if (strncmp(argv[4], "cross", 5) == 0)
		{
			printf("test_move(%d, %d, %s, %d, %d, %d)\n", initial_x, initial_y, "cross", horizontal, distance, time);

			return test_move(initial_x, initial_y, cross, horizontal, distance, time);
		}
		else if (strncmp(argv[4], "pic3", 4) == 0)
		{
			printf("test_move(%d, %d, %s, %d, %d, %d)\n", initial_x, initial_y, "pic3", horizontal, distance, time);

			return test_move(initial_x, initial_y, pic3, horizontal, distance, time);
		}
		else if (strncmp(argv[4], "penguin", 7) == 0)
		{
			printf("test_move(%d, %d, %s, %d, %d, %d)\n", initial_x, initial_y, "penguin", horizontal, distance, time);

			return test_move(initial_x, initial_y, penguin, horizontal, distance, time);
		}

	}
	else if(strncmp(argv[1], "controller", 10) == 0)
	{
		printf("test_controller()\n");

		return test_controller();
	}
	else
	{
		printf("non valid function \"%s\" to test\n", argv[1]);
		return 1;
	}
}
Example #30
0
int
main(int argc, char **argv)
{
    krb5_context context;
    krb5_error_code ret;
    int optidx = 0;
    krb5_ccache id1, id2;

    setprogname(argv[0]);

    if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &optidx))
	usage(1);

    if (help_flag)
	usage (0);

    if(version_flag){
	print_version(NULL);
	exit(0);
    }

    argc -= optidx;
    argv += optidx;

    ret = krb5_init_context(&context);
    if (ret)
	errx (1, "krb5_init_context failed: %d", ret);

    test_cache_remove(context, krb5_cc_type_file);
    test_cache_remove(context, krb5_cc_type_memory);
#ifdef USE_SQLITE
    test_cache_remove(context, krb5_cc_type_scc);
#endif

    test_default_name(context);
    test_mcache(context);
    test_init_vs_destroy(context, krb5_cc_type_memory);
    test_init_vs_destroy(context, krb5_cc_type_file);
#if 0
    test_init_vs_destroy(context, krb5_cc_type_api);
#endif
    test_init_vs_destroy(context, krb5_cc_type_scc);
    test_mcc_default();
    test_def_cc_name(context);

    test_cache_iter_all(context);

    test_cache_iter(context, krb5_cc_type_memory, 0);
    {
	krb5_principal p;
	krb5_cc_new_unique(context, krb5_cc_type_memory, "bar", &id1);
	krb5_cc_new_unique(context, krb5_cc_type_memory, "baz", &id2);
	krb5_parse_name(context, "*****@*****.**", &p);
	krb5_cc_initialize(context, id1, p);
	krb5_free_principal(context, p);
    }

    test_cache_find(context, "*****@*****.**", 1);
    test_cache_find(context, "*****@*****.**", 0);

    test_cache_iter(context, krb5_cc_type_memory, 0);
    test_cache_iter(context, krb5_cc_type_memory, 1);
    test_cache_iter(context, krb5_cc_type_memory, 0);
    test_cache_iter(context, krb5_cc_type_file, 0);
    test_cache_iter(context, krb5_cc_type_api, 0);
    test_cache_iter(context, krb5_cc_type_scc, 0);
    test_cache_iter(context, krb5_cc_type_scc, 1);

    test_copy(context, krb5_cc_type_file, krb5_cc_type_file);
    test_copy(context, krb5_cc_type_memory, krb5_cc_type_memory);
    test_copy(context, krb5_cc_type_file, krb5_cc_type_memory);
    test_copy(context, krb5_cc_type_memory, krb5_cc_type_file);
    test_copy(context, krb5_cc_type_scc, krb5_cc_type_file);
    test_copy(context, krb5_cc_type_file, krb5_cc_type_scc);
    test_copy(context, krb5_cc_type_scc, krb5_cc_type_memory);
    test_copy(context, krb5_cc_type_memory, krb5_cc_type_scc);

    test_move(context, krb5_cc_type_file);
    test_move(context, krb5_cc_type_memory);
#ifdef HAVE_KCM
    test_move(context, krb5_cc_type_kcm);
#endif
    test_move(context, krb5_cc_type_scc);

    test_prefix_ops(context, "FILE:/tmp/foo", &krb5_fcc_ops);
    test_prefix_ops(context, "FILE", &krb5_fcc_ops);
    test_prefix_ops(context, "MEMORY", &krb5_mcc_ops);
    test_prefix_ops(context, "MEMORY:foo", &krb5_mcc_ops);
    test_prefix_ops(context, "/tmp/kaka", &krb5_fcc_ops);
#ifdef HAVE_SCC
    test_prefix_ops(context, "SCC:", &krb5_scc_ops);
    test_prefix_ops(context, "SCC:foo", &krb5_scc_ops);
#endif

    krb5_cc_destroy(context, id1);
    krb5_cc_destroy(context, id2);

    test_cc_config(context);

    krb5_free_context(context);

#if 0
    sleep(60);
#endif

    return 0;
}