Exemplo n.º 1
0
int main(int argc, char **argv) {
  grpc_test_init(argc, argv);
  test_simple_int();
  test_eq_int();
  test_2dash_int();
  test_2dash_eq_int();
  test_simple_string();
  test_eq_string();
  test_2dash_string();
  test_2dash_eq_string();
  test_flag_on();
  test_flag_no();
  test_flag_val_1();
  test_flag_val_0();
  test_flag_val_true();
  test_flag_val_false();
  test_many();
  test_usage();
  return 0;
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
    unsigned int a, b, i, j;
    int c, d;
    unsigned char e, f;
    int num_failed = 0, num_all = 0;
    fprintf(stdout, "Testing constant time operations...\n");

    for (i = 0; i < OSSL_NELEM(test_values); ++i) {
        a = test_values[i];
        num_failed += test_is_zero(a);
        num_failed += test_is_zero_8(a);
        num_all += 2;
        for (j = 0; j < OSSL_NELEM(test_values); ++j) {
            b = test_values[j];
            num_failed += test_binary_op(&constant_time_lt,
                                         "constant_time_lt", a, b, a < b);
            num_failed += test_binary_op_8(&constant_time_lt_8,
                                           "constant_time_lt_8", a, b, a < b);
            num_failed += test_binary_op(&constant_time_lt,
                                         "constant_time_lt_8", b, a, b < a);
            num_failed += test_binary_op_8(&constant_time_lt_8,
                                           "constant_time_lt_8", b, a, b < a);
            num_failed += test_binary_op(&constant_time_ge,
                                         "constant_time_ge", a, b, a >= b);
            num_failed += test_binary_op_8(&constant_time_ge_8,
                                           "constant_time_ge_8", a, b,
                                           a >= b);
            num_failed +=
                test_binary_op(&constant_time_ge, "constant_time_ge", b, a,
                               b >= a);
            num_failed +=
                test_binary_op_8(&constant_time_ge_8, "constant_time_ge_8", b,
                                 a, b >= a);
            num_failed +=
                test_binary_op(&constant_time_eq, "constant_time_eq", a, b,
                               a == b);
            num_failed +=
                test_binary_op_8(&constant_time_eq_8, "constant_time_eq_8", a,
                                 b, a == b);
            num_failed +=
                test_binary_op(&constant_time_eq, "constant_time_eq", b, a,
                               b == a);
            num_failed +=
                test_binary_op_8(&constant_time_eq_8, "constant_time_eq_8", b,
                                 a, b == a);
            num_failed += test_select(a, b);
            num_all += 13;
        }
    }

    for (i = 0; i < OSSL_NELEM(signed_test_values); ++i) {
        c = signed_test_values[i];
        for (j = 0; j < OSSL_NELEM(signed_test_values); ++j) {
            d = signed_test_values[j];
            num_failed += test_select_int(c, d);
            num_failed += test_eq_int(c, d);
            num_failed += test_eq_int_8(c, d);
            num_all += 3;
        }
    }

    for (i = 0; i < sizeof(test_values_8); ++i) {
        e = test_values_8[i];
        for (j = 0; j < sizeof(test_values_8); ++j) {
            f = test_values_8[j];
            num_failed += test_select_8(e, f);
            num_all += 1;
        }
    }

    if (!num_failed) {
        fprintf(stdout, "ok (ran %d tests)\n", num_all);
        return EXIT_SUCCESS;
    } else {
        fprintf(stdout, "%d of %d tests failed!\n", num_failed, num_all);
        return EXIT_FAILURE;
    }
}