Esempio n. 1
0
void ManualPoller::poll_write(int, int evtfd, void* data)
{
    EXPECT_TRUE(this->has_pollee(evtfd)) << evtfd << " in " << data;
    pollees[evtfd] = EV_HUP | EV_READ | EV_WRITE;
}
Esempio n. 2
0
	static void Exec(void * params) {
		OrderParams* order_params = static_cast<OrderParams*>(params);
		g_exec_order++;
		EXPECT_TRUE(g_exec_order == order_params->total_ - order_params->put_order_);
	}
Esempio n. 3
0
TEST(String, Informational) {
  EXPECT_TRUE(String().isNull());
  EXPECT_TRUE(!String("").isNull());
  EXPECT_TRUE(String().empty());
  EXPECT_TRUE(String("").empty());
  EXPECT_TRUE(!String("test").empty());
  EXPECT_TRUE(String().size() == 0);
  EXPECT_TRUE(String().length() == 0);
  EXPECT_TRUE(String("").size() == 0);
  EXPECT_TRUE(String("").length() == 0);
  EXPECT_TRUE(String("test").size() == 4);
  EXPECT_TRUE(String("test").length() == 4);
  EXPECT_TRUE(!String("2test").isNumeric());
  EXPECT_TRUE(!String("2test").isInteger());
  EXPECT_TRUE(!String("test").isNumeric());
  EXPECT_TRUE(!String("test").isInteger());
  EXPECT_TRUE(String("23").isNumeric());
  EXPECT_TRUE(String("23").isInteger());
  EXPECT_TRUE(String("23.3").isNumeric());
  EXPECT_TRUE(!String("23.3").isInteger());
}
inline void invoke_recoding(recoding_parameters param)
{
    // Common setting
    typename Encoder::factory encoder_factory(
        param.m_max_symbols, param.m_max_symbol_size);

    encoder_factory.set_symbols(param.m_symbols);
    encoder_factory.set_symbol_size(param.m_symbol_size);

    auto encoder = encoder_factory.build();

    typename Decoder::factory decoder_factory(
        param.m_max_symbols, param.m_max_symbol_size);

    decoder_factory.set_symbols(param.m_symbols);
    decoder_factory.set_symbol_size(param.m_symbol_size);

    auto decoder_one = decoder_factory.build();
    auto decoder_two = decoder_factory.build();

    // If tested with a shallow decoder we have to remember to set the
    // buffers to use for the decoding
    std::vector<uint8_t> buffer_decoder_one(decoder_one->block_size(), '\0');
    std::vector<uint8_t> buffer_decoder_two(decoder_two->block_size(), '\0');

    if(kodo::has_shallow_symbol_storage<Decoder>::value)
    {
        decoder_one->set_symbols(sak::storage(buffer_decoder_one));
        decoder_two->set_symbols(sak::storage(buffer_decoder_two));
    }

    EXPECT_EQ(encoder->payload_size(), decoder_one->payload_size());
    EXPECT_EQ(encoder->payload_size(), decoder_two->payload_size());

    std::vector<uint8_t> payload(encoder->payload_size());
    std::vector<uint8_t> data_in = random_vector(encoder->block_size());

    encoder->set_symbols(sak::storage(data_in));

    // Set the encoder non-systematic
    if(kodo::has_systematic_encoder<Encoder>::value)
        kodo::set_systematic_off(encoder);

    while( !decoder_two->is_complete() )
    {
        uint32_t encode_size = encoder->encode( &payload[0] );
        EXPECT_TRUE(encode_size <= payload.size());
        EXPECT_TRUE(encode_size > 0);

        decoder_one->decode( &payload[0] );

        uint32_t recode_size = decoder_one->recode( &payload[0] );
        EXPECT_TRUE(recode_size <= payload.size());
        EXPECT_TRUE(recode_size > 0);

        decoder_two->decode( &payload[0] );
    }

    std::vector<uint8_t> data_out_one(decoder_one->block_size(), '\0');
    std::vector<uint8_t> data_out_two(decoder_two->block_size(), '\0');

    decoder_one->copy_symbols(sak::storage(data_out_one));
    decoder_two->copy_symbols(sak::storage(data_out_two));

    EXPECT_TRUE(std::equal(data_out_one.begin(),
                           data_out_one.end(),
                           data_in.begin()));

    EXPECT_TRUE(std::equal(data_out_two.begin(),
                           data_out_two.end(),
                           data_in.begin()));
}
Esempio n. 5
0
  void IntegerBasicTest()
  {
    Dissent::Crypto::Integer int0(5);
    Dissent::Crypto::Integer int1(6);

    EXPECT_NE(int0, int1);
    EXPECT_EQ(int0, int1 - 1);
    EXPECT_EQ(int0 + 1, int1);
    EXPECT_TRUE(int0 < int1);
    EXPECT_TRUE(int1 > int0);
    EXPECT_TRUE(int0 <= int1);
    EXPECT_TRUE(int1 >= int0);
    EXPECT_TRUE(int0 + 1 <= int1);
    EXPECT_TRUE(int1 - 1 >= int0);

    std::swap(int0, int1);

    EXPECT_NE(int0, int1);
    EXPECT_EQ(int0, int1 + 1);
    EXPECT_EQ(int0 - 1, int1);
    EXPECT_TRUE(int0 > int1);
    EXPECT_TRUE(int1 < int0);
    EXPECT_TRUE(int0 >= int1);
    EXPECT_TRUE(int1 <= int0);
    EXPECT_TRUE(int0 - 1 >= int1);
    EXPECT_TRUE(int1 + 1 <= int0);

    EXPECT_EQ(int0 * int1, Integer(30));
    EXPECT_EQ(Integer(30) / int0, int1);
    EXPECT_EQ(Integer(30) / int1, int0);
  }
TEST(stanMcmcDiagEStaticHmc,headerParses) {
  EXPECT_TRUE(true);
}
Esempio n. 7
0
TEST_F(TimeSmokeTest, simpleAbsoluteTime)
{
    timeHandle = xme_hal_time_handleFromAbsoluteTime(&someTime);
    EXPECT_TRUE(xme_hal_time_isValidTimeHandle(timeHandle));
}
Esempio n. 8
0
TEST_F(SQLiteUtilTests, test_simple_query_execution) {
  // Access to the internal SQL implementation is only available in core.
  auto sql = SQL("SELECT * FROM time");
  EXPECT_TRUE(sql.ok());
  EXPECT_EQ(sql.rows().size(), 1U);
}
 void resultTypeMustBe() {
   EXPECT_TRUE(_result.is<T>());
 }
TEST_F(NodeSmokeTest, initIteratorOnNonInitedNodeTableWithValidInterface)
{
    xme_core_directory_nodeRegistryController_nodeInterfaceIterator_t *iterator=NULL;
    EXPECT_EQ(XME_STATUS_NOT_FOUND, xme_core_directory_nodeRegistryController_initNodeInterfaceIterator((xme_core_node_nodeId_t)1, XME_COM_INTERFACE_ADDRESS_TYPE_IPV4, &iterator));
    EXPECT_TRUE(NULL==iterator);
}
TEST_F(NodeSmokeTest, initIteratorWithInvalidNodeIdOnNonInitedNodeTableWithInvalidInterface)
{
    xme_core_directory_nodeRegistryController_nodeInterfaceIterator_t *iterator=NULL;
    EXPECT_EQ(XME_STATUS_INVALID_PARAMETER, xme_core_directory_nodeRegistryController_initNodeInterfaceIterator(XME_CORE_NODE_INVALID_NODE_ID, XME_COM_INTERFACE_ADDRESS_TYPE_INVALID, &iterator));
    EXPECT_TRUE(NULL==iterator);
}
Esempio n. 12
0
TEST(hash_trie, trivial) {
  HashTrie t;
  read_t a = str_to_read("A");
  read_t ab = str_to_read("AB");
  read_t abc = str_to_read("ABC");
  read_t abd = str_to_read("ABD");
  id_t i_a = 0;
  id_t i_abc = 2;
  id_t i_abd = 3;

  t.insert(abc, i_abc, 1);
  // [abc]
  t.print(cout);

  read_t r;
  id_t w;
  t.get_ith(abc, 0, w, r);
  EXPECT_EQ(i_abc, w);
  EXPECT_EQ(abc, r);

  t.insert(abc, i_abc, 1);
  // [abc, abc]
  t.get_ith(ab, 0, w, r);
  EXPECT_EQ(i_abc, w);
  EXPECT_EQ(abc, r);
  t.get_ith(ab, 1, w, r);
  EXPECT_EQ(i_abc, w);
  EXPECT_EQ(abc, r);

  t.insert(abd, i_abd, 1);
  // [abc, abc, abd]
  // Order for C and D is not defined
  read_t r1, r2, r3;
  id_t w1, w2, w3;
  t.get_ith(ab, 0, w1, r1);
  t.get_ith(ab, 1, w2, r2);
  t.get_ith(ab, 2, w3, r3);
  EXPECT_TRUE(
      (w1 == i_abc && w2 == i_abc && w3 == i_abd &&
       r1 == abc && r2 == abc && r3 == abd) ||
      (w1 == i_abd && w2 == i_abc && w3 == i_abc &&
       r1 == abd && r2 == abc && r3 == abc));

  t.print(cout);
  EXPECT_EQ(3u, t.count_total(ab));
  EXPECT_EQ(3u, t.count_total(a));
  EXPECT_EQ(1u, t.count_total(abd));


  t.insert(a, i_a, 1);
  // [a, abc, abc, abd]
  t.print(cout);
  t.get_ith(a, 0, w, r);
  EXPECT_EQ(i_a, w);
  EXPECT_EQ(a, r);

  t.get_ith(a, 1, w1, r1);
  t.get_ith(a, 2, w2, r2);
  t.get_ith(a, 3, w3, r3);

  EXPECT_TRUE(
      (w1 == i_abc && w2 == i_abc && w3 == i_abd &&
       r1 == abc && r2 == abc && r3 == abd) ||
      (w1 == i_abd && w2 == i_abc && w3 == i_abc &&
       r1 == abd && r2 == abc && r3 == abc));
}
Esempio n. 13
0
void ManualPoller::clear_pollee_events(int evtfd)
{
    EXPECT_TRUE(this->has_pollee(evtfd));
    pollees[evtfd] = 0;
}
Esempio n. 14
0
void ManualPoller::poll_del(int, int evtfd)
{
    EXPECT_TRUE(this->has_pollee(evtfd)) << evtfd;
    pollees.erase(evtfd);
}
Esempio n. 15
0
TEST_F(XmlFasadeTest, hello){
	EXPECT_TRUE(true);
}
Esempio n. 16
0
 void AWorxUnitTesting::EQ( const TString& file, int line, const TString& func, const String&  exp, const String&   s )        { if (!exp.Equals(s))                  Failed(file,line,func,String128("\"") << exp << "\", \"" << s << "\" given."); EXPECT_TRUE ( exp.Equals(s)     ); }
TEST(KeyboardmasterUT, Test)
{
	EXPECT_TRUE(true);
}
Esempio n. 18
0
 void AWorxUnitTesting::ISTRUE ( const TString& file, int line, const TString& func, bool cond )                               { if (  !cond )                        Failed(file,line,func,String128() << "true"                                     ); EXPECT_TRUE ( cond              ); }
Esempio n. 19
0
TEST(MruCache, InitialEmpty) {
  TestCache c(kCacheCapacity);
  EXPECT_TRUE(c.GetMostRecentlyUsed() == NULL);
}
Esempio n. 20
0
TEST(logcat, descriptive) {
    struct tag {
        uint32_t tagNo;
        const char* tagStr;
    };

    {
        static const struct tag hhgtg = { 42, "answer" };
        android_log_event_list ctx(hhgtg.tagNo);
        static const char theAnswer[] = "what is five by seven";
        ctx << theAnswer;
        ctx.write();
        EXPECT_TRUE(End_to_End(hhgtg.tagStr,
                               "to life the universe etc=%s", theAnswer));
    }

    {
        static const struct tag sync = { 2720, "sync" };
        static const char id[] = "logcat.decriptive";
        {
            android_log_event_list ctx(sync.tagNo);
            ctx << id << (int32_t)42 << (int32_t)-1 << (int32_t)0;
            ctx.write();
            EXPECT_TRUE(End_to_End(sync.tagStr,
                                   "[id=%s,event=42,source=-1,account=0]",
                                   id));
        }

        // Partial match to description
        {
            android_log_event_list ctx(sync.tagNo);
            ctx << id << (int32_t)43 << (int64_t)-1 << (int32_t)0;
            ctx.write();
            EXPECT_TRUE(End_to_End(sync.tagStr,
                                   "[id=%s,event=43,-1,0]",
                                   id));
        }

        // Negative Test of End_to_End, ensure it is working
        {
            android_log_event_list ctx(sync.tagNo);
            ctx << id << (int32_t)44 << (int32_t)-1 << (int64_t)0;
            ctx.write();
            fprintf(stderr, "Expect a \"Closest match\" message\n");
            EXPECT_FALSE(End_to_End(sync.tagStr,
                                    "[id=%s,event=44,source=-1,account=0]",
                                    id));
        }
    }

    {
        static const struct tag sync = { 2747, "contacts_aggregation" };
        {
            android_log_event_list ctx(sync.tagNo);
            ctx << (uint64_t)30 << (int32_t)2;
            ctx.write();
            EXPECT_TRUE(End_to_End(sync.tagStr,
                                   "[aggregation time=30ms,count=2]"));
        }

        {
            android_log_event_list ctx(sync.tagNo);
            ctx << (uint64_t)31570 << (int32_t)911;
            ctx.write();
            EXPECT_TRUE(End_to_End(sync.tagStr,
                                   "[aggregation time=31.57s,count=911]"));
        }
    }

    {
        static const struct tag sync = { 75000, "sqlite_mem_alarm_current" };
        {
            android_log_event_list ctx(sync.tagNo);
            ctx << (uint32_t)512;
            ctx.write();
            EXPECT_TRUE(End_to_End(sync.tagStr, "current=512B"));
        }

        {
            android_log_event_list ctx(sync.tagNo);
            ctx << (uint32_t)3072;
            ctx.write();
            EXPECT_TRUE(End_to_End(sync.tagStr, "current=3KB"));
        }

        {
            android_log_event_list ctx(sync.tagNo);
            ctx << (uint32_t)2097152;
            ctx.write();
            EXPECT_TRUE(End_to_End(sync.tagStr, "current=2MB"));
        }

        {
            android_log_event_list ctx(sync.tagNo);
            ctx << (uint32_t)2097153;
            ctx.write();
            EXPECT_TRUE(End_to_End(sync.tagStr, "current=2097153B"));
        }

        {
            android_log_event_list ctx(sync.tagNo);
            ctx << (uint32_t)1073741824;
            ctx.write();
            EXPECT_TRUE(End_to_End(sync.tagStr, "current=1GB"));
        }

        {
            android_log_event_list ctx(sync.tagNo);
            ctx << (uint32_t)3221225472; // 3MB, but on purpose overflowed
            ctx.write();
            EXPECT_TRUE(End_to_End(sync.tagStr, "current=-1GB"));
        }
    }

    {
        static const struct tag sync = { 27501, "notification_panel_hidden" };
        android_log_event_list ctx(sync.tagNo);
        ctx.write();
        EXPECT_TRUE(End_to_End(sync.tagStr, ""));
    }
}
Esempio n. 21
0
TEST(is_hdd, linux_os_root)
{
  std::string path = "/";
  EXPECT_TRUE(tools::is_hdd(path.c_str()) != boost::none);
}
Esempio n. 22
0
int get_groups(const char *cmd) {
    FILE *fp;

    // NB: crash log only available in user space
    EXPECT_TRUE(NULL != (fp = popen(cmd, "r")));

    if (fp == NULL) {
        return 0;
    }

    char buffer[BIG_BUFFER];

    int count = 0;

    while (fgets(buffer, sizeof(buffer), fp)) {
        int size, consumed, max, payload;
        char size_mult[3], consumed_mult[3];
        long full_size, full_consumed;

        size = consumed = max = payload = 0;
        // NB: crash log can be very small, not hit a Kb of consumed space
        //     doubly lucky we are not including it.
        if (6 != sscanf(buffer, "%*s ring buffer is %d%2s (%d%2s consumed),"
                                " max entry is %db, max payload is %db",
                                &size, size_mult, &consumed, consumed_mult,
                                &max, &payload)) {
            fprintf(stderr, "WARNING: Parse error: %s", buffer);
            continue;
        }
        full_size = size;
        switch(size_mult[0]) {
        case 'G':
            full_size *= 1024;
            /* FALLTHRU */
        case 'M':
            full_size *= 1024;
            /* FALLTHRU */
        case 'K':
            full_size *= 1024;
            /* FALLTHRU */
        case 'b':
            break;
        }
        full_consumed = consumed;
        switch(consumed_mult[0]) {
        case 'G':
            full_consumed *= 1024;
            /* FALLTHRU */
        case 'M':
            full_consumed *= 1024;
            /* FALLTHRU */
        case 'K':
            full_consumed *= 1024;
            /* FALLTHRU */
        case 'b':
            break;
        }
        EXPECT_GT((full_size * 9) / 4, full_consumed);
        EXPECT_GT(full_size, max);
        EXPECT_GT(max, payload);

        if ((((full_size * 9) / 4) >= full_consumed)
         && (full_size > max)
         && (max > payload)) {
            ++count;
        }
    }

    pclose(fp);

    return count;
}
void CheckFixedNullableResultType(const Type &cast_type) {
  const UnaryOperation &op = NumericCastOperation::Instance(cast_type);
  const Type *fixed_result_type = op.fixedNullableResultType();
  ASSERT_NE(fixed_result_type, nullptr);
  EXPECT_TRUE(cast_type.getNullableVersion().equals(*fixed_result_type));
}
Esempio n. 24
0
TEST(logcat, logrotate_continue) {
    static const char tmp_out_dir_form[] = "/data/local/tmp/logcat.logrotate.XXXXXX";
    char tmp_out_dir[sizeof(tmp_out_dir_form)];
    ASSERT_TRUE(NULL != mkdtemp(strcpy(tmp_out_dir, tmp_out_dir_form)));

    static const char log_filename[] = "log.txt";
    static const char logcat_cmd[] = "logcat -b all -d -f %s/%s -n 256 -r 1024";
    static const char cleanup_cmd[] = "rm -rf %s";
    char command[sizeof(tmp_out_dir) + sizeof(logcat_cmd) + sizeof(log_filename)];
    snprintf(command, sizeof(command), logcat_cmd, tmp_out_dir, log_filename);

    int ret;
    EXPECT_FALSE(IsFalse(ret = system(command), command));
    if (ret) {
        snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
        EXPECT_FALSE(IsFalse(system(command), command));
        return;
    }
    FILE *fp;
    snprintf(command, sizeof(command), "%s/%s", tmp_out_dir, log_filename);
    EXPECT_TRUE(NULL != ((fp = fopen(command, "r"))));
    if (!fp) {
        snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
        EXPECT_FALSE(IsFalse(system(command), command));
        return;
    }
    char *line = NULL;
    char *last_line = NULL; // this line is allowed to stutter, one-line overlap
    char *second_last_line = NULL;
    size_t len = 0;
    while (getline(&line, &len, fp) != -1) {
        free(second_last_line);
        second_last_line = last_line;
        last_line = line;
        line = NULL;
    }
    fclose(fp);
    free(line);
    if (second_last_line == NULL) {
        fprintf(stderr, "No second to last line, using last, test may fail\n");
        second_last_line = last_line;
        last_line = NULL;
    }
    free(last_line);
    EXPECT_TRUE(NULL != second_last_line);
    if (!second_last_line) {
        snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
        EXPECT_FALSE(IsFalse(system(command), command));
        return;
    }
    // re-run the command, it should only add a few lines more content if it
    // continues where it left off.
    snprintf(command, sizeof(command), logcat_cmd, tmp_out_dir, log_filename);
    EXPECT_FALSE(IsFalse(ret = system(command), command));
    if (ret) {
        snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
        EXPECT_FALSE(IsFalse(system(command), command));
        return;
    }
    std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(tmp_out_dir), closedir);
    EXPECT_NE(nullptr, dir);
    if (!dir) {
        snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
        EXPECT_FALSE(IsFalse(system(command), command));
        return;
    }
    struct dirent *entry;
    unsigned count = 0;
    while ((entry = readdir(dir.get()))) {
        if (strncmp(entry->d_name, log_filename, sizeof(log_filename) - 1)) {
            continue;
        }
        snprintf(command, sizeof(command), "%s/%s", tmp_out_dir, entry->d_name);
        EXPECT_TRUE(NULL != ((fp = fopen(command, "r"))));
        if (!fp) {
            fprintf(stderr, "%s ?\n", command);
            continue;
        }
        line = NULL;
        size_t number = 0;
        while (getline(&line, &len, fp) != -1) {
            ++number;
            if (!strcmp(line, second_last_line)) {
                EXPECT_TRUE(++count <= 1);
                fprintf(stderr, "%s(%zu):\n", entry->d_name, number);
            }
        }
        fclose(fp);
        free(line);
        unlink(command);
    }
    if (count > 1) {
        char *brk = strpbrk(second_last_line, "\r\n");
        if (!brk) {
            brk = second_last_line + strlen(second_last_line);
        }
        fprintf(stderr, "\"%.*s\" occured %u times\n",
            (int)(brk - second_last_line), second_last_line, count);
    }
    free(second_last_line);

    snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir);
    EXPECT_FALSE(IsFalse(system(command), command));
}
Esempio n. 25
0
TEST_F(UsesAnalysisTests,
AnalysisHasNonEmptyID) {
	EXPECT_TRUE(!usesAnalysis.getName().empty()) <<
		"the analyzer should have a non-empty ID";
}
Esempio n. 26
0
TEST( skinning_large_cube, skinning_large_cube)
{
  stk::ParallelMachine pm = MPI_COMM_WORLD;

  const size_t p_size = stk::parallel_machine_size(pm);
  const size_t p_rank = stk::parallel_machine_rank(pm);

  // Every processor will be involved in detachment and skin-update up to 500 processors.
  // This puts 5000 elements on each process unless we are running with STL
  // in debug mode in which case we shrink the problem down in order
  // to keep things running in a reasonable amount of time.
#ifdef _GLIBCXX_DEBUG
  const size_t NX = p_size*10, NY = 4, NZ = 5;
#else
  const size_t NX = p_size*100, NY = 100, NZ = 100;
#endif

  static const int TIMER_COUNT = 6;
  /* timings[0] = create mesh
   * timings[1] = intial skin mesh
   * timings[2] = detach mesh
   * timings[3] = delete skin
   * timings[4] = reskin mesh
   * timings[5] = sum(timings[0:4])
   */
  double timings[TIMER_COUNT] = {0};
  double timing_sums[TIMER_COUNT] = {0};
  const char* timer_names[TIMER_COUNT] = {"Create mesh", "Initial skin", "Detach mesh", "Delete skin", "Reskin", "Total time"};
  double start_time = 0;
  size_t memory_max[2] = {0};
  const char* memory_names[2] = {"Current memory", "Memory high water"};

  //recreate skin
  for ( int test_run = 0; test_run < 4; ++test_run) {
    //create the mesh

    start_time = stk::wall_time();
    stk::mesh::fixtures::HexFixture fixture(pm,NX,NY,NZ);
    const EntityRank element_rank = stk::topology::ELEMENT_RANK;
    const EntityRank side_rank = fixture.m_meta.side_rank();

    stk::mesh::MetaData & fem_meta = fixture.m_meta;
    stk::mesh::BulkData & mesh = fixture.m_bulk_data;

    stk::mesh::Part & skin_part = fem_meta.declare_part("skin_part");
    fem_meta.commit();

    fixture.generate_mesh();
    timings[0] = stk::wall_dtime(start_time);

    //intial skin of the mesh
    start_time = stk::wall_time();
    {
      stk::mesh::PartVector add_parts(1,&skin_part);
      stk::mesh::skin_mesh(mesh, add_parts);
    }
    timings[1] = stk::wall_dtime(start_time);

    stk::mesh::EntityVector entities_to_separate;

    if ( test_run < 2) {
      //detach 1/3 of the mesh
      size_t num_detached_this_proc = 0;
      for (size_t ix=NX/3; ix < 2*NX/3; ++ix) {
      for (size_t iy=0; iy < NY; ++iy) {
      for (size_t iz=0; iz < NZ; ++iz) {
        stk::mesh::Entity element = fixture.elem(ix,iy,iz);
        if (mesh.is_valid(element) && mesh.parallel_owner_rank(element) == mesh.parallel_rank()) {
          entities_to_separate.push_back(element);
          num_detached_this_proc++;
        }
      }
      }
      }
      EXPECT_TRUE( num_detached_this_proc > 0u );
    } else {
      //detach middle of the mesh
      for (size_t ix=NX/2; ix < NX/2+1; ++ix) {
      for (size_t iy=NY/2; iy < NY/2+1; ++iy) {
      for (size_t iz=NZ/2; iz < NZ/2+1; ++iz) {
        stk::mesh::Entity element = fixture.elem(ix,iy,iz);
        if (mesh.is_valid(element) && mesh.parallel_owner_rank(element) == mesh.parallel_rank()) {
          entities_to_separate.push_back(element);
        }
      }
      }
      }
    }

    start_time = stk::wall_time();
    separate_and_skin_mesh(
        fem_meta,
        mesh,
        skin_part,
        entities_to_separate
        );
    timings[2] = stk::wall_dtime(start_time);

    if (test_run%2 == 0) { // delete the skin
      start_time = stk::wall_time();
      delete_skin( mesh, skin_part, side_rank );
      timings[3] = stk::wall_dtime(start_time);

      //reskin the entire mesh
      start_time = stk::wall_time();
      {
        stk::mesh::PartVector add_parts(1,&skin_part);
        stk::mesh::skin_mesh( mesh, add_parts);
      }
      timings[4] = stk::wall_dtime(start_time);
    }
    else { //update the skin
      timings[3] = 0;

      //update the skin of the mesh
      start_time = stk::wall_time();
      update_skin( mesh, &skin_part, element_rank);
      timings[4] = stk::wall_dtime(start_time);
    }

    //total the timings
    timings[5] = 0;
    for (int i=0; i <5; ++i) {
      timings[5] += timings[i];
    }

    size_t mem_now = 0, mem_hwm = 0;
    stk::get_memory_usage(mem_now, mem_hwm);

    stk::all_reduce(pm, stk::ReduceMax<5>(timings));
    stk::all_reduce(pm, stk::ReduceMax<1>(&mem_now));
    stk::all_reduce(pm, stk::ReduceMax<1>(&mem_hwm));

    if (mem_now > memory_max[0]) {
      memory_max[0] = mem_now;
    }
    if (mem_hwm > memory_max[1]) {
      memory_max[1] = mem_hwm;
    }

    //compute sums
    for (int i=0; i<TIMER_COUNT; ++i) {
      timing_sums[i] += timings[i];
    }

    if (p_rank == 0) {
      std::cout << "\n\n";
      switch (test_run) {
        case 0:
          std::cout << "Recreate entire skin after detaching 1/3 of the mesh:\n";
          break;
        case 1:
          std::cout << "Update skin after detaching 1/3 of the mesh:\n";
          break;
        case 2:
          std::cout << "Recreate entire skin after detaching middle of the mesh:\n";
          break;
        case 3:
          std::cout << "Update skin after detaching middle of the mesh:\n";
          break;
      }

      std::cout << "Num procs: " << p_size << "\n";
      std::cout << "Mesh size: " << NX << 'x' << NY << 'x' << NZ << " = " << NX*NY*NZ << " elements\n";
      std::cout << "Total time: "     << timings[5] << "\n";
      std::cout << "\tCreate mesh: "  << timings[0] << "\n";
      std::cout << "\tInitial skin: " << timings[1] << "\n";
      std::cout << "\tDetach mesh: "  << timings[2] << "\n";
      std::cout << "\tDelete skin: "  << timings[3] << "\n";
      std::cout << "\tReskin:      "  << timings[4] << "\n";
      std::cout << "\n\n";
    }

    size_t num_skin_entities = count_skin_entities(mesh, skin_part, side_rank );

    stk::all_reduce(pm, stk::ReduceSum<1>(&num_skin_entities));

    size_t expected_num_skin = 0;

    if ( test_run < 2) {
      expected_num_skin = 2*(NX*NY + NX*NZ + 3*NY*NZ);
    } else {
      expected_num_skin = 2*(NX*NY + NX*NZ + NY*NZ) + 12;
    }

    EXPECT_EQ( num_skin_entities, expected_num_skin );
  }

  if (p_rank == 0) {
    stk::print_timers_and_memory(&timer_names[0], &timing_sums[0], TIMER_COUNT, &memory_names[0], &memory_max[0], 2);
  }

  stk::parallel_print_time_without_output_and_hwm(pm, timings[5]);
}
Esempio n. 27
0
TEST_F(EventsDatabaseTests, test_event_add) {
  auto sub = std::make_shared<FakeEventSubscriber>();
  auto status = sub->testAdd(1);
  EXPECT_TRUE(status.ok());
}
Esempio n. 28
0
TEST_F(PerfTest, Parse)
{
  // uint64 and floats should be parsed.
  Try<hashmap<string, mesos::PerfStatistics> > parse =
    perf::parse("123,cycles\n0.123,task-clock");
  CHECK_SOME(parse);

  ASSERT_TRUE(parse.get().contains(""));
  mesos::PerfStatistics statistics = parse.get().get("").get();

  ASSERT_TRUE(statistics.has_cycles());
  EXPECT_EQ(123u, statistics.cycles());
  ASSERT_TRUE(statistics.has_task_clock());
  EXPECT_EQ(0.123, statistics.task_clock());

  // Parse multiple cgroups.
  parse = perf::parse("123,cycles,cgroup1\n"
                      "456,cycles,cgroup2\n"
                      "0.456,task-clock,cgroup2\n"
                      "0.123,task-clock,cgroup1");
  CHECK_SOME(parse);
  EXPECT_FALSE(parse.get().contains(""));

  ASSERT_TRUE(parse.get().contains("cgroup1"));
  statistics = parse.get().get("cgroup1").get();

  ASSERT_TRUE(statistics.has_cycles());
  EXPECT_EQ(123u, statistics.cycles());
  ASSERT_TRUE(statistics.has_task_clock());
  EXPECT_EQ(0.123, statistics.task_clock());

  ASSERT_TRUE(parse.get().contains("cgroup2"));
  statistics = parse.get().get("cgroup2").get();

  ASSERT_TRUE(statistics.has_cycles());
  EXPECT_EQ(456u, statistics.cycles());
  EXPECT_TRUE(statistics.has_task_clock());
  EXPECT_EQ(0.456, statistics.task_clock());

  // Statistics reporting <not supported> should not appear.
  parse = perf::parse("<not supported>,cycles");
  CHECK_SOME(parse);

  ASSERT_TRUE(parse.get().contains(""));
  statistics = parse.get().get("").get();
  EXPECT_FALSE(statistics.has_cycles());

  // Statistics reporting <not counted> should be zero.
  parse = perf::parse("<not counted>,cycles\n<not counted>,task-clock");
  CHECK_SOME(parse);

  ASSERT_TRUE(parse.get().contains(""));
  statistics = parse.get().get("").get();

  EXPECT_TRUE(statistics.has_cycles());
  EXPECT_EQ(0u, statistics.cycles());
  EXPECT_TRUE(statistics.has_task_clock());
  EXPECT_EQ(0.0, statistics.task_clock());

  // Check parsing fails.
  parse = perf::parse("1,cycles\ngarbage");
  EXPECT_ERROR(parse);

  parse = perf::parse("1,unknown-field");
  EXPECT_ERROR(parse);
}
Esempio n. 29
0
TEST(String, Compare) {
  EXPECT_TRUE(String("abc").compare("abc") == 0);
  EXPECT_TRUE(String("abc").compare("bbc") < 0);
  EXPECT_TRUE(String("bbc").compare("abc") > 0);
  EXPECT_TRUE(String("abc").compare(String("abc")) == 0);
  EXPECT_TRUE(String("abc").compare(String("bbc")) < 0);
  EXPECT_TRUE(String("bbc").compare(String("abc")) > 0);

  EXPECT_TRUE(String("abc").compare("abcd") < 0);
  EXPECT_TRUE(String("abcd").compare("abc") > 0);
  EXPECT_TRUE(String("abc").compare(String("abcd")) < 0);
  EXPECT_TRUE(String("abcd").compare(String("abc")) > 0);

  // check Strings with embedded nulls
  std::string str1("a\0bc", 4);
  std::string str2("a\0bb", 4);
  EXPECT_TRUE(String(str1).compare(String(str1)) == 0);
  EXPECT_TRUE(String(str1).compare(String(str2)) > 0);
  EXPECT_TRUE(String(str2).compare(String(str1)) < 0);
}
Esempio n. 30
0
// Ensure that features are enabled / disabled correctly when the FP runtime
// flag is turned off.
TEST_F(FeaturePolicyInFrameTest, TestFeatureDefaultsWhenFPDisabled) {
  RuntimeEnabledFeatures::setFeaturePolicyEnabled(false);
  EXPECT_TRUE(isFeatureEnabledInFrame(kDefaultOnFeature, frame()));
  EXPECT_TRUE(isFeatureEnabledInFrame(kDefaultSelfFeature, frame()));
  EXPECT_FALSE(isFeatureEnabledInFrame(kDefaultOffFeature, frame()));
}