Exemple #1
0
ATF_TC_BODY(exec_unknown, tc)
{
    char buf[1024];
    snprintf(buf, sizeof(buf), "%s/non-existent",
             atf_config_get("atf_workdir"));

    const char *argv[2];
    argv[0] = buf;
    argv[1] = NULL;

    atf_check_result_t result;
    RE(atf_check_exec_array(argv, &result));
    ATF_CHECK(atf_check_result_exited(&result));
    ATF_CHECK(atf_check_result_exitcode(&result) == 127);
    atf_check_result_fini(&result);
}
Exemple #2
0
static void do_exec (const atf_tc_t * tc, const char *helper_name, atf_process_status_t * s)
{
    atf_fs_path_t process_helpers;

    const char *argv[3];

    get_process_helpers_path (tc, true, &process_helpers);

    argv[0] = atf_fs_path_cstring (&process_helpers);
    argv[1] = helper_name;
    argv[2] = NULL;
    printf ("Executing %s %s\n", argv[0], argv[1]);

    RE (atf_process_exec_array (s, &process_helpers, argv, NULL, NULL));
    atf_fs_path_fini (&process_helpers);
}
Exemple #3
0
void testRange(std::string const & filename)
{
	::libmaus::autoarray::AutoArray<uint8_t> data = ::libmaus::util::GetFileSize::readFile(filename);
	unsigned int const alph = 256;
	for ( uint64_t i = 0; i < data.size(); ++i )
		data[i] &= (alph-1);

	::libmaus::timing::RealTimeClock rtc; rtc.start();
	unsigned int const loops = 3;
	std::ostringstream ostr;
	
	for ( unsigned int l = 0; l < loops; ++l )
	{
		::libmaus::arithmetic::RangeEncoder<std::ostream> RE(ostr);
		model_type MDenc(alph);
		for ( uint64_t i = 0; i < data.size(); ++i )
			RE.encodeUpdate(MDenc,data[i]);
		RE.flush();
	}
	
	double const enctime = rtc.getElapsedSeconds();
	std::cerr << "encoding time " << enctime/loops << " compression " << 
		(
			static_cast<double>(3*data.size()) / ostr.str().size()
		) 
	<< std::endl;
	
	bool ok = true;
	std::istringstream istr(ostr.str());
	rtc.start();
	
	for ( unsigned int l = 0; ok && l < loops; ++l )
	{
		model_type MDdec(alph);
		::libmaus::arithmetic::RangeDecoder<std::istream> RD(istr);
		::libmaus::autoarray::AutoArray<uint8_t> ddata(data.size(),false);
		for ( uint64_t i = 0; i < data.size(); ++i )
		{
			ddata[i] = RD.decodeUpdate(MDdec);
			ok = ok && (data[i] == ddata[i]);
		}
	}
	double const dectime = rtc.getElapsedSeconds();
	std::cerr << "decoding time " << dectime/loops << std::endl;
		
	std::cerr << "range coder " << (ok ? "ok" : "failed") << std::endl;
}
static S caut_enc_get_byte_combination(SEI * ei, TD const * td, TEI * ti, bool * progress, uint8_t * byte) {
    struct iter_combination * const iter = &ti->prototype.c_combination;
    struct caut_combination const * const desc = &td->prototype.c_combination;

    uint64_t word = 0;
    memcpy(&word, ti->type, caut_tag_size(desc->tag));

    if (iter->tag_iter.tag_position < caut_tag_size(desc->tag)) {
        // still accumulating tag
        uint64_t const mask = mask_with_width(desc->field_count);
        if (word > mask) {
            return caut_status_err_invalid_combination;
        } else if (NULL == byte) {
            return caut_status_err_need_byte;
        } else {
            *progress = true;
            *byte = ((uint8_t *)&word)[iter->tag_iter.tag_position];
            iter->tag_iter.tag_position += 1;

            return caut_status_ok_busy;
        }
    } else {
        while (iter->field_position < desc->field_count) {
            uint64_t const field_flag = flag_set_at(iter->field_position);

            if (0 == (field_flag & word)) {
                iter->field_position += 1;
                continue;
            } else {
                struct caut_field const * const field = &desc->fields[iter->field_position];
                void const * base = (void *)(((uintptr_t)ti->type) + field->offset);

                iter->field_position += 1;

                if (field->data) {
                    RE(push_type_enc_iter(ei, field->ref_id, base));
                    return caut_status_ok_pushed;
                } else {
                    continue;
                }
            }
        }

        return caut_status_ok_pop;
    }
}
static S caut_enc_get_byte_synonym(SEI * ei, TD const * td, TEI * ti, bool * progress, uint8_t * byte) {
    (void)byte;

    struct iter_synonym * const iter = &ti->prototype.c_synonym;
    struct caut_synonym const * const desc = &td->prototype.c_synonym;

    *progress = false;

    if (iter->done == false) {
        RE(push_type_enc_iter(ei, desc->ref_id, ti->type));
        iter->done = true;

        return caut_status_ok_pushed;
    } else {
        return caut_status_ok_pop;
    }
}
Exemple #6
0
static
void
do_exec(const atf_tc_t *tc, const char *helper_name, atf_check_result_t *r)
{
    atf_fs_path_t process_helpers;
    const char *argv[3];

    get_process_helpers_path(tc, false, &process_helpers);

    argv[0] = atf_fs_path_cstring(&process_helpers);
    argv[1] = helper_name;
    argv[2] = NULL;
    printf("Executing %s %s\n", argv[0], argv[1]);
    RE(atf_check_exec_array(argv, r));

    atf_fs_path_fini(&process_helpers);
}
Exemple #7
0
ATF_TC_BODY(rfind_ch, tc)
{
    atf_dynstr_t str;

    RE(atf_dynstr_init_fmt(&str, "Foo1/Bar2/,.Baz"));

    ATF_REQUIRE_EQ(atf_dynstr_rfind_ch(&str, '\0'), atf_dynstr_npos);

    ATF_REQUIRE_EQ(atf_dynstr_rfind_ch(&str, '0'), atf_dynstr_npos);
    ATF_REQUIRE_EQ(atf_dynstr_rfind_ch(&str, 'b'), atf_dynstr_npos);

    ATF_REQUIRE_EQ(atf_dynstr_rfind_ch(&str, 'F'), 0);
    ATF_REQUIRE_EQ(atf_dynstr_rfind_ch(&str, '/'), 9);
    ATF_REQUIRE_EQ(atf_dynstr_rfind_ch(&str, 'a'), 13);
    ATF_REQUIRE_EQ(atf_dynstr_rfind_ch(&str, 'z'), 14);

    atf_dynstr_fini(&str);
}
Exemple #8
0
ATF_TC_BODY(path_normalize, tc)
{
    struct test {
        const char *in;
        const char *out;
    } tests[] = {
        { ".", ".", },
        { "..", "..", },

        { "/", "/", },
        { "//", "/", }, /* NO_CHECK_STYLE */
        { "///", "/", }, /* NO_CHECK_STYLE */

        { "foo", "foo", },
        { "foo/", "foo", },
        { "foo/bar", "foo/bar", },
        { "foo/bar/", "foo/bar", },

        { "/foo", "/foo", },
        { "/foo/bar", "/foo/bar", },
        { "/foo/bar/", "/foo/bar", },

        { "///foo", "/foo", }, /* NO_CHECK_STYLE */
        { "///foo///bar", "/foo/bar", }, /* NO_CHECK_STYLE */
        { "///foo///bar///", "/foo/bar", }, /* NO_CHECK_STYLE */

        { NULL, NULL }
    };
    struct test *t;

    for (t = &tests[0]; t->in != NULL; t++) {
        atf_fs_path_t p;

        printf("Input          : >%s<\n", t->in);
        printf("Expected output: >%s<\n", t->out);

        RE(atf_fs_path_init_fmt(&p, "%s", t->in));
        printf("Output         : >%s<\n", atf_fs_path_cstring(&p));
        ATF_REQUIRE(strcmp(atf_fs_path_cstring(&p), t->out) == 0);
        atf_fs_path_fini(&p);

        printf("\n");
    }
}
Exemple #9
0
ATF_TC_BODY(mkstemp_ok, tc)
{
    int fd1, fd2;
    atf_fs_path_t p1, p2;
    atf_fs_stat_t s1, s2;

    RE(atf_fs_path_init_fmt(&p1, "testfile.XXXXXX"));
    RE(atf_fs_path_init_fmt(&p2, "testfile.XXXXXX"));
    fd1 = fd2 = -1;
    RE(atf_fs_mkstemp(&p1, &fd1));
    RE(atf_fs_mkstemp(&p2, &fd2));
    ATF_REQUIRE(!atf_equal_fs_path_fs_path(&p1, &p2));
    ATF_REQUIRE(exists(&p1));
    ATF_REQUIRE(exists(&p2));

    ATF_CHECK(fd1 != -1);
    ATF_CHECK(fd2 != -1);
    ATF_CHECK(write(fd1, "foo", 3) == 3);
    ATF_CHECK(write(fd2, "bar", 3) == 3);
    close(fd1);
    close(fd2);

    RE(atf_fs_stat_init(&s1, &p1));
    ATF_CHECK_EQ(atf_fs_stat_get_type(&s1), atf_fs_stat_reg_type);
    ATF_CHECK( atf_fs_stat_is_owner_readable(&s1));
    ATF_CHECK( atf_fs_stat_is_owner_writable(&s1));
    ATF_CHECK(!atf_fs_stat_is_owner_executable(&s1));
    ATF_CHECK(!atf_fs_stat_is_group_readable(&s1));
    ATF_CHECK(!atf_fs_stat_is_group_writable(&s1));
    ATF_CHECK(!atf_fs_stat_is_group_executable(&s1));
    ATF_CHECK(!atf_fs_stat_is_other_readable(&s1));
    ATF_CHECK(!atf_fs_stat_is_other_writable(&s1));
    ATF_CHECK(!atf_fs_stat_is_other_executable(&s1));

    RE(atf_fs_stat_init(&s2, &p2));
    ATF_CHECK_EQ(atf_fs_stat_get_type(&s2), atf_fs_stat_reg_type);
    ATF_CHECK( atf_fs_stat_is_owner_readable(&s2));
    ATF_CHECK( atf_fs_stat_is_owner_writable(&s2));
    ATF_CHECK(!atf_fs_stat_is_owner_executable(&s2));
    ATF_CHECK(!atf_fs_stat_is_group_readable(&s2));
    ATF_CHECK(!atf_fs_stat_is_group_writable(&s2));
    ATF_CHECK(!atf_fs_stat_is_group_executable(&s2));
    ATF_CHECK(!atf_fs_stat_is_other_readable(&s2));
    ATF_CHECK(!atf_fs_stat_is_other_writable(&s2));
    ATF_CHECK(!atf_fs_stat_is_other_executable(&s2));

    atf_fs_stat_fini(&s2);
    atf_fs_stat_fini(&s1);
    atf_fs_path_fini(&p2);
    atf_fs_path_fini(&p1);
}
Exemple #10
0
ATF_TC_BODY(rmdir_enotempty, tc)
{
    atf_fs_path_t p;
    atf_error_t err;

    RE(atf_fs_path_init_fmt(&p, "test-dir"));

    ATF_REQUIRE(mkdir("test-dir", 0755) != -1);
    ATF_REQUIRE(exists(&p));
    create_file("test-dir/foo", 0644);

    err = atf_fs_rmdir(&p);
    ATF_REQUIRE(atf_is_error(err));
    ATF_REQUIRE(atf_error_is(err, "libc"));
    ATF_REQUIRE_EQ(atf_libc_error_code(err), ENOTEMPTY);
    atf_error_free(err);

    atf_fs_path_fini(&p);
}
Exemple #11
0
ATF_TC_BODY(mkdtemp_err, tc)
{
    atf_error_t err;
    atf_fs_path_t p;

    ATF_REQUIRE(mkdir("dir", 0555) != -1);

    RE(atf_fs_path_init_fmt(&p, "dir/testdir.XXXXXX"));

    err = atf_fs_mkdtemp(&p);
    ATF_REQUIRE(atf_is_error(err));
    ATF_REQUIRE(atf_error_is(err, "libc"));
    ATF_CHECK_EQ(atf_libc_error_code(err), EACCES);
    atf_error_free(err);

    ATF_CHECK(!exists(&p));
    ATF_CHECK(strcmp(atf_fs_path_cstring(&p), "dir/testdir.XXXXXX") == 0);

    atf_fs_path_fini(&p);
}
Exemple #12
0
static
void
check_prepend(atf_error_t (*prepend)(atf_dynstr_t *, const char *, ...))
{
    const size_t maxlen = 8192;
    char buf[maxlen + 1];
    size_t i;
    atf_dynstr_t str;

    printf("Prepending with plain string\n");
    buf[0] = '\0';
    RE(atf_dynstr_init(&str));
    for (i = 0; i < maxlen; i++) {
        if (strcmp(atf_dynstr_cstring(&str), buf) != 0) {
            fprintf(stderr, "Failed at iteration %zd\n", i);
            atf_tc_fail("Failed to prepend character at iteration %zd", i);
        }

        memmove(buf + 1, buf, i + 1);
        if (i % 2 == 0) {
            RE(prepend(&str, "%s", "a"));
            buf[0] = 'a';
        } else {
            RE(prepend(&str, "%s", "b"));
            buf[0] = 'b';
        }
    }
    atf_dynstr_fini(&str);

    printf("Prepending with formatted string\n");
    buf[0] = '\0';
    RE(atf_dynstr_init(&str));
    for (i = 0; i < maxlen; i++) {
        if (strcmp(atf_dynstr_cstring(&str), buf) != 0) {
            fprintf(stderr, "Failed at iteration %zd\n", i);
            atf_tc_fail("Failed to prepend character at iteration %zd", i);
        }

        memmove(buf + 1, buf, i + 1);
        if (i % 2 == 0) {
            RE(prepend(&str, "%s", "a"));
            buf[0] = 'a';
        } else {
            RE(prepend(&str, "%s", "b"));
            buf[0] = 'b';
        }
    }
    atf_dynstr_fini(&str);
}
Exemple #13
0
ATF_TC_BODY (status_coredump, tc)
{
    struct rlimit rl;

    rl.rlim_cur = RLIM_INFINITY;
    rl.rlim_max = RLIM_INFINITY;
    if (setrlimit (RLIMIT_CORE, &rl) == -1)
        atf_tc_skip ("Cannot unlimit the core file size; check limits " "manually");

    const int rawstatus = fork_and_wait_child (child_sigquit);

    atf_process_status_t s;

    RE (atf_process_status_init (&s, rawstatus));
    ATF_CHECK (!atf_process_status_exited (&s));
    ATF_CHECK (atf_process_status_signaled (&s));
    ATF_CHECK_EQ (atf_process_status_termsig (&s), SIGQUIT);
    ATF_CHECK (atf_process_status_coredump (&s));
    atf_process_status_fini (&s);
}
Exemple #14
0
static void redirect_fd_stream_init (void *v)
{
    struct redirect_fd_stream *s = v;

    switch (s->m_base.m_type)
    {
        case stdout_type:
            s->m_fd = open ("stdout", O_WRONLY | O_CREAT | O_TRUNC, 0644);
            break;
        case stderr_type:
            s->m_fd = open ("stderr", O_WRONLY | O_CREAT | O_TRUNC, 0644);
            break;
        default:
            UNREACHABLE;
    }
    ATF_REQUIRE (s->m_fd != -1);

    s->m_base.m_sb_ptr = &s->m_base.m_sb;
    RE (atf_process_stream_init_redirect_fd (&s->m_base.m_sb, s->m_fd));
}
Exemple #15
0
ATF_TC_BODY(rewrite__too_long_with_newlines, tc)
{
    char input[1000];
    fill_buffer("failed: ", "line\n", input, sizeof(input));

    // This is quite awful but is the price we have to pay for using fixed-size
    // buffers in the code for simplicity and speed...
    char exp_output[1024 + 8 /* strlen("failed: ") */ + 1];
    fill_buffer("failed: ", "line<<NEWLINE>>", exp_output, sizeof(exp_output));
    exp_output[sizeof(exp_output) - 2] = '\n';

    bool success;
    atf_utils_create_file("in.txt", "%s", input);
    RE(kyua_atf_result_rewrite("in.txt", "out.txt",
                               generate_wait_exitstatus(EXIT_FAILURE),
                               false, &success));
    atf_utils_cat_file("out.txt", "OUTPUT:   ");
    printf("EXPECTED: %s", exp_output);
    ATF_REQUIRE(atf_utils_compare_file("out.txt", exp_output));
    ATF_REQUIRE_EQ(false, success);
}
static S caut_enc_get_byte_array(SEI * ei, TD const * td, TEI * ti, bool * progress, uint8_t * byte) {
    struct iter_array * const iter = &ti->prototype.c_array;
    struct caut_array const * const desc = &td->prototype.c_array;

    *progress = false;
    (void) byte;

    if (iter->elem_position < desc->length) {
        void const * base =
            (void *)(
                ((uintptr_t)ti->type) +
                (desc->elem_span * iter->elem_position));

        RE(push_type_enc_iter(ei, desc->ref_id, base));
        iter->elem_position += 1;

        return caut_status_ok_pushed;
    } else {
        return caut_status_ok_pop;
    }
}
Exemple #17
0
void PA_HeldObjectMove(Ts *ts, Obj *held, Obj *grid, GridCoord torow,
                       GridCoord tocol)
{
  ObjList	*objs, *p;
  /* (S8) -> (S2)+(S6): Held object which moves is no longer
   * inside anything. (Holding overrides inside.)
   * todo: Actor holds key in pocket while walking.
   */
  TE(ts, L(N("inside"), held, ObjWild, E));

  if (grid) { /* Optimization. */
    /* (S7): <held> is small container. */
    objs = RE(ts, L(N("inside"), ObjWild, held, E));
    for (p = objs; p; p = p->next) {
      PA_SmallContainedObjectMove(ts, I(p->obj, 1), grid, torow, tocol);
    }
    ObjListFree(objs);
  }

  PA_MoveObject(ts, held, grid, torow, tocol);
}
Exemple #18
0
ATF_TC_BODY(init_rep, tc)
{
    const size_t maxlen = 8192;
    char buf[maxlen + 1];
    size_t i;

    buf[0] = '\0';

    for (i = 0; i < maxlen; i++) {
        atf_dynstr_t str;

        RE(atf_dynstr_init_rep(&str, i, 'a'));

        if (strcmp(atf_dynstr_cstring(&str), buf) != 0) {
            fprintf(stderr, "Failed at iteration %zd\n", i);
            atf_tc_fail("Failed to construct dynstr by repeating %zd "
                        "times the '%c' character", i, 'a');
        }

        atf_dynstr_fini(&str);

        strcat(buf, "a");
    }

    {
        atf_dynstr_t str;
        atf_error_t err;

        err = atf_dynstr_init_rep(&str, SIZE_MAX, 'a');
        ATF_REQUIRE(atf_is_error(err));
        ATF_REQUIRE(atf_error_is(err, "no_memory"));
        atf_error_free(err);

        err = atf_dynstr_init_rep(&str, SIZE_MAX - 1, 'a');
        ATF_REQUIRE(atf_is_error(err));
        ATF_REQUIRE(atf_error_is(err, "no_memory"));
        atf_error_free(err);
    }
}
Exemple #19
0
// Populate __pointers section.
void RuntimeDyldMachO::populateIndirectSymbolPointersSection(
                                                    const MachOObjectFile &Obj,
                                                    const SectionRef &PTSection,
                                                    unsigned PTSectionID) {
  assert(!Obj.is64Bit() &&
         "Pointer table section not supported in 64-bit MachO.");

  MachO::dysymtab_command DySymTabCmd = Obj.getDysymtabLoadCommand();
  MachO::section Sec32 = Obj.getSection(PTSection.getRawDataRefImpl());
  uint32_t PTSectionSize = Sec32.size;
  unsigned FirstIndirectSymbol = Sec32.reserved1;
  const unsigned PTEntrySize = 4;
  unsigned NumPTEntries = PTSectionSize / PTEntrySize;
  unsigned PTEntryOffset = 0;

  assert((PTSectionSize % PTEntrySize) == 0 &&
         "Pointers section does not contain a whole number of stubs?");

  DEBUG(dbgs() << "Populating pointer table section "
               << Sections[PTSectionID].getName() << ", Section ID "
               << PTSectionID << ", " << NumPTEntries << " entries, "
               << PTEntrySize << " bytes each:\n");

  for (unsigned i = 0; i < NumPTEntries; ++i) {
    unsigned SymbolIndex =
      Obj.getIndirectSymbolTableEntry(DySymTabCmd, FirstIndirectSymbol + i);
    symbol_iterator SI = Obj.getSymbolByIndex(SymbolIndex);
    ErrorOr<StringRef> IndirectSymbolNameOrErr = SI->getName();
    if (std::error_code EC = IndirectSymbolNameOrErr.getError())
      report_fatal_error(EC.message());
    StringRef IndirectSymbolName = *IndirectSymbolNameOrErr;
    DEBUG(dbgs() << "  " << IndirectSymbolName << ": index " << SymbolIndex
          << ", PT offset: " << PTEntryOffset << "\n");
    RelocationEntry RE(PTSectionID, PTEntryOffset,
                       MachO::GENERIC_RELOC_VANILLA, 0, false, 2);
    addRelocationForSymbol(RE, IndirectSymbolName);
    PTEntryOffset += PTEntrySize;
  }
}
Exemple #20
0
static void passf2pos_sse(const uint16_t l1, const complex_t *cc,
                          complex_t *ch, const complex_t *wa)
{
    uint16_t k, ah, ac;

    for (k = 0; k < l1; k++)
    {
        ah = 2*k;
        ac = 4*k;

        RE(ch[ah])    = RE(cc[ac]) + RE(cc[ac+1]);
        IM(ch[ah])    = IM(cc[ac]) + IM(cc[ac+1]);

        RE(ch[ah+l1]) = RE(cc[ac]) - RE(cc[ac+1]);
        IM(ch[ah+l1]) = IM(cc[ac]) - IM(cc[ac+1]);
    }
}
static S caut_enc_get_byte_record(SEI * ei, TD const * td, TEI * ti, bool * progress, uint8_t * byte) {
    struct iter_record * const iter = &ti->prototype.c_record;
    struct caut_record const * const desc = &td->prototype.c_record;

    (void) byte;
    *progress = false;

    if (iter->field_position < desc->field_count) {
        struct caut_field const * const field = &desc->fields[iter->field_position];
        void const * base = (void *)(((uintptr_t)ti->type) + field->offset);

        if (field->data == false) {
            return caut_status_err_invalid_record;
        } else {
            RE(push_type_enc_iter(ei, field->ref_id, base));
            iter->field_position += 1;
        }

        return caut_status_ok_pushed;
    } else {
        return caut_status_ok_pop;
    }
}
Exemple #22
0
ATF_TC_BODY(rmdir_eperm, tc)
{
    atf_fs_path_t p;
    atf_error_t err;

    RE(atf_fs_path_init_fmt(&p, "test-dir/foo"));

    ATF_REQUIRE(mkdir("test-dir", 0755) != -1);
    ATF_REQUIRE(mkdir("test-dir/foo", 0755) != -1);
    ATF_REQUIRE(chmod("test-dir", 0555) != -1);
    ATF_REQUIRE(exists(&p));

    err = atf_fs_rmdir(&p);
    if (atf_user_is_root()) {
        ATF_REQUIRE(!atf_is_error(err));
    } else {
        ATF_REQUIRE(atf_is_error(err));
        ATF_REQUIRE(atf_error_is(err, "libc"));
        ATF_REQUIRE_EQ(atf_libc_error_code(err), EACCES);
        atf_error_free(err);
    }

    atf_fs_path_fini(&p);
}
static S caut_enc_get_byte_vector(SEI * ei, TD const * td, TEI * ti, bool * progress, uint8_t * byte) {
    struct iter_vector * const iter = &ti->prototype.c_vector;
    struct caut_vector const * const desc = &td->prototype.c_vector;

    uint64_t word = 0;
    memcpy(&word, ti->type, caut_tag_size(desc->tag));

    if (iter->tag_iter.tag_position < caut_tag_size(desc->tag)) {
        // still accumulating tag
        if (word > desc->max_length) {
            return caut_status_err_invalid_vector;
        } else if (NULL == byte) {
            return caut_status_err_need_byte;
        } else {
            *progress = true;
            *byte = ((uint8_t *)&word)[iter->tag_iter.tag_position];
            iter->tag_iter.tag_position += 1;

            return caut_status_ok_busy;
        }
    } else if (iter->elem_position < word) {
        // accumulating elements
        void const * base =
            (void *)(
                ((uintptr_t)ti->type) +
                desc->elem_offset +
                (desc->elem_span * iter->elem_position));

        RE(push_type_enc_iter(ei, desc->ref_id, base));
        iter->elem_position += 1;

        return caut_status_ok_pushed;
    } else {
        return caut_status_ok_pop;
    }
}
Exemple #24
0
/* SUBGOAL move-to na ?grasper ?object */
void PA_MoveTo(Context *cx, Subgoal *sg, Ts *ts, Obj *a, Obj *o)
{
  Obj	*p;
  Dur	d;
  Dbg(DBGPLAN, DBGOK, "PA_MoveTo", E);
  switch (sg->state) {
    case STBEGIN:
      if (!(p = DbRetrieveWhole(ts, NULL, N("human"), I(o, 2)))) goto failure;
      if (p != a) {
        Dbg(DBGPLAN, DBGDETAIL, "failure: grasper not part of actor", E);
        goto failure;
      }
      SG(cx, sg, 1, STFAILURE, L(N("near-reachable"), p, I(o,3), E));
      return;
    case 1:
      if ((p = R1E(ts, L(N("inside"), I(o,3), ObjWild, E))) &&
          YES(RE(ts, L(N("closed"), I(p, 2), E)))) {
        SG(cx, sg, 2, STFAILURE, L(N("open"), I(p, 2), E));
      } else {
        TOSTATE(cx, sg, 2);
      }
      return;
    case 2:
      PA_GrasperMove(ts, I(o, 2), NULL, 0, 0);

      d = DurationOf(I(o, 0));
      AA(ts, d, o);
      TsIncrement(ts, d);
      AS(ts, 0, L(N("near-graspable"), I(o,2), I(o,3), E));
      TOSTATE(cx, sg, STSUCCESS);
      return;
    default: Dbg(DBGPLAN, DBGBAD, "PA_MoveTo: undefined state %d", sg->state);
  }
failure:
  TOSTATE(cx, sg, STFAILURE);
}
Exemple #25
0
ATF_TC_BODY(exec_cleanup, tc)
{
    atf_fs_path_t out, err;
    atf_check_result_t result;
    bool exists;

    do_exec(tc, "exit-success", &result);
    RE(atf_fs_path_init_fmt(&out, "%s", atf_check_result_stdout(&result)));
    RE(atf_fs_path_init_fmt(&err, "%s", atf_check_result_stderr(&result)));

    RE(atf_fs_exists(&out, &exists)); ATF_CHECK(exists);
    RE(atf_fs_exists(&err, &exists)); ATF_CHECK(exists);
    atf_check_result_fini(&result);
    RE(atf_fs_exists(&out, &exists)); ATF_CHECK(!exists);
    RE(atf_fs_exists(&err, &exists)); ATF_CHECK(!exists);

    atf_fs_path_fini(&err);
    atf_fs_path_fini(&out);
}
Exemple #26
0
ATF_TC_BODY(mkdtemp_ok, tc)
{
    atf_fs_path_t p1, p2;
    atf_fs_stat_t s1, s2;

    RE(atf_fs_path_init_fmt(&p1, "testdir.XXXXXX"));
    RE(atf_fs_path_init_fmt(&p2, "testdir.XXXXXX"));
    RE(atf_fs_mkdtemp(&p1));
    RE(atf_fs_mkdtemp(&p2));
    ATF_REQUIRE(!atf_equal_fs_path_fs_path(&p1, &p2));
    ATF_REQUIRE(exists(&p1));
    ATF_REQUIRE(exists(&p2));

    RE(atf_fs_stat_init(&s1, &p1));
    ATF_REQUIRE_EQ(atf_fs_stat_get_type(&s1), atf_fs_stat_dir_type);
    ATF_REQUIRE( atf_fs_stat_is_owner_readable(&s1));
    ATF_REQUIRE( atf_fs_stat_is_owner_writable(&s1));
    ATF_REQUIRE( atf_fs_stat_is_owner_executable(&s1));
    ATF_REQUIRE(!atf_fs_stat_is_group_readable(&s1));
    ATF_REQUIRE(!atf_fs_stat_is_group_writable(&s1));
    ATF_REQUIRE(!atf_fs_stat_is_group_executable(&s1));
    ATF_REQUIRE(!atf_fs_stat_is_other_readable(&s1));
    ATF_REQUIRE(!atf_fs_stat_is_other_writable(&s1));
    ATF_REQUIRE(!atf_fs_stat_is_other_executable(&s1));

    RE(atf_fs_stat_init(&s2, &p2));
    ATF_REQUIRE_EQ(atf_fs_stat_get_type(&s2), atf_fs_stat_dir_type);
    ATF_REQUIRE( atf_fs_stat_is_owner_readable(&s2));
    ATF_REQUIRE( atf_fs_stat_is_owner_writable(&s2));
    ATF_REQUIRE( atf_fs_stat_is_owner_executable(&s2));
    ATF_REQUIRE(!atf_fs_stat_is_group_readable(&s2));
    ATF_REQUIRE(!atf_fs_stat_is_group_writable(&s2));
    ATF_REQUIRE(!atf_fs_stat_is_group_executable(&s2));
    ATF_REQUIRE(!atf_fs_stat_is_other_readable(&s2));
    ATF_REQUIRE(!atf_fs_stat_is_other_writable(&s2));
    ATF_REQUIRE(!atf_fs_stat_is_other_executable(&s2));

    atf_fs_stat_fini(&s2);
    atf_fs_stat_fini(&s1);
    atf_fs_path_fini(&p2);
    atf_fs_path_fini(&p1);
}
Exemple #27
0
ATF_TC_BODY (fork_cookie, tc)
{
    atf_process_stream_t outsb, errsb;

    RE (atf_process_stream_init_inherit (&outsb));
    RE (atf_process_stream_init_inherit (&errsb));

    {
        atf_process_child_t child;

        atf_process_status_t status;

        RE (atf_process_fork (&child, child_cookie, &outsb, &errsb, NULL));
        RE (atf_process_child_wait (&child, &status));

        ATF_CHECK (atf_process_status_exited (&status));
        ATF_CHECK_EQ (atf_process_status_exitstatus (&status), exit_v_null);

        atf_process_status_fini (&status);
    }

    {
        atf_process_child_t child;

        atf_process_status_t status;

        int dummy_int;

        RE (atf_process_fork (&child, child_cookie, &outsb, &errsb, &dummy_int));
        RE (atf_process_child_wait (&child, &status));

        ATF_CHECK (atf_process_status_exited (&status));
        ATF_CHECK_EQ (atf_process_status_exitstatus (&status), exit_v_notnull);

        atf_process_status_fini (&status);
    }

    atf_process_stream_fini (&errsb);
    atf_process_stream_fini (&outsb);
}
Exemple #28
0
/// Performs a signal delivery test to the work directory handling code.
///
/// \param signo The signal to deliver.
static void
work_directory_signal_check(const int signo)
{
    char* tmpdir;
    RE(kyua_fs_make_absolute("worktest", &tmpdir));
    ATF_REQUIRE(mkdir(tmpdir, 0755) != -1);
    RE(kyua_env_set("TMPDIR", tmpdir));

    char* work_directory;
    RE(kyua_run_work_directory_enter("template.XXXXXX", getuid(), getgid(),
                                     &work_directory));

    kyua_run_params_t run_params;
    kyua_run_params_init(&run_params);
    run_params.work_directory = work_directory;

    pid_t pid;
    RE(kyua_run_fork(&run_params, &pid));
    if (pid == 0) {
        sleep(run_params.timeout_seconds * 2);
        abort();
    }

    // This should cause the handled installed by the work_directory management
    // code to terminate the subprocess so that we get a chance to run the
    // cleanup code ourselves.
    kill(getpid(), signo);

    int status; bool timed_out;
    RE(kyua_run_wait(pid, &status, &timed_out));
    ATF_REQUIRE(!timed_out);
    ATF_REQUIRE(WIFSIGNALED(status));
    ATF_REQUIRE_EQ(SIGKILL, WTERMSIG(status));

    ATF_REQUIRE(rmdir(tmpdir) == -1);  // Not yet empty.
    RE(kyua_run_work_directory_leave(&work_directory));
    ATF_REQUIRE(rmdir(tmpdir) != -1);
    free(tmpdir);
}
Exemple #29
0
static void passf2pos_sse_ido(const uint16_t ido, const uint16_t l1, const complex_t *cc,
                              complex_t *ch, const complex_t *wa)
{
    uint16_t i, k, ah, ac;

    for (k = 0; k < l1; k++)
    {
        ah = k*ido;
        ac = 2*k*ido;

        for (i = 0; i < ido; i+=4)
        {
            __m128 m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14;
            __m128 m15, m16, m17, m18, m19, m20, m21, m22, m23, m24;
            __m128 w1, w2, w3, w4;

            m1 = _mm_load_ps(&RE(cc[ac+i]));
            m2 = _mm_load_ps(&RE(cc[ac+ido+i]));
            m5 = _mm_load_ps(&RE(cc[ac+i+2]));
            m6 = _mm_load_ps(&RE(cc[ac+ido+i+2]));
            w1 = _mm_load_ps(&RE(wa[i]));
            w3 = _mm_load_ps(&RE(wa[i+2]));

            m3 = _mm_add_ps(m1, m2);
            m15 = _mm_add_ps(m5, m6);

            m4 = _mm_sub_ps(m1, m2);
            m16 = _mm_sub_ps(m5, m6);

            _mm_store_ps(&RE(ch[ah+i]), m3);
            _mm_store_ps(&RE(ch[ah+i+2]), m15);


            w2 = _mm_shuffle_ps(w1, w1, _MM_SHUFFLE(2, 3, 0, 1));
            w4 = _mm_shuffle_ps(w3, w3, _MM_SHUFFLE(2, 3, 0, 1));

            m7 = _mm_mul_ps(m4, w1);
            m17 = _mm_mul_ps(m16, w3);
            m8 = _mm_mul_ps(m4, w2);
            m18 = _mm_mul_ps(m16, w4);

            m9  = _mm_shuffle_ps(m7, m8, _MM_SHUFFLE(2, 0, 2, 0));
            m19 = _mm_shuffle_ps(m17, m18, _MM_SHUFFLE(2, 0, 2, 0));
            m10 = _mm_shuffle_ps(m7, m8, _MM_SHUFFLE(3, 1, 3, 1));
            m20 = _mm_shuffle_ps(m17, m18, _MM_SHUFFLE(3, 1, 3, 1));

            m11 = _mm_add_ps(m9, m10);
            m21 = _mm_add_ps(m19, m20);
            m12 = _mm_sub_ps(m9, m10);
            m22 = _mm_sub_ps(m19, m20);

            m13 = _mm_shuffle_ps(m11, m11, _MM_SHUFFLE(0, 0, 3, 2));
            m23 = _mm_shuffle_ps(m21, m21, _MM_SHUFFLE(0, 0, 3, 2));

            m14 = _mm_unpacklo_ps(m12, m13);
            m24 = _mm_unpacklo_ps(m22, m23);

            _mm_store_ps(&RE(ch[ah+i+l1*ido]), m14);
            _mm_store_ps(&RE(ch[ah+i+2+l1*ido]), m24);
        }
    }
}
Exemple #30
0
static void passf3(const uint16_t ido, const uint16_t l1, const complex_t *cc,
                   complex_t *ch, const complex_t *wa1, const complex_t *wa2,
                   const int8_t isign)
{
    static real_t taur = FRAC_CONST(-0.5);
    static real_t taui = FRAC_CONST(0.866025403784439);
    uint16_t i, k, ac, ah;
    complex_t c2, c3, d2, d3, t2;

    if (ido == 1)
    {
        if (isign == 1)
        {
            for (k = 0; k < l1; k++)
            {
                ac = 3*k+1;
                ah = k;

                RE(t2) = RE(cc[ac]) + RE(cc[ac+1]);
                IM(t2) = IM(cc[ac]) + IM(cc[ac+1]);
                RE(c2) = RE(cc[ac-1]) + MUL_F(RE(t2),taur);
                IM(c2) = IM(cc[ac-1]) + MUL_F(IM(t2),taur);

                RE(ch[ah]) = RE(cc[ac-1]) + RE(t2);
                IM(ch[ah]) = IM(cc[ac-1]) + IM(t2);

                RE(c3) = MUL_F((RE(cc[ac]) - RE(cc[ac+1])), taui);
                IM(c3) = MUL_F((IM(cc[ac]) - IM(cc[ac+1])), taui);

                RE(ch[ah+l1]) = RE(c2) - IM(c3);
                IM(ch[ah+l1]) = IM(c2) + RE(c3);
                RE(ch[ah+2*l1]) = RE(c2) + IM(c3);
                IM(ch[ah+2*l1]) = IM(c2) - RE(c3);
            }
        } else {
            for (k = 0; k < l1; k++)
            {
                ac = 3*k+1;
                ah = k;

                RE(t2) = RE(cc[ac]) + RE(cc[ac+1]);
                IM(t2) = IM(cc[ac]) + IM(cc[ac+1]);
                RE(c2) = RE(cc[ac-1]) + MUL_F(RE(t2),taur);
                IM(c2) = IM(cc[ac-1]) + MUL_F(IM(t2),taur);

                RE(ch[ah]) = RE(cc[ac-1]) + RE(t2);
                IM(ch[ah]) = IM(cc[ac-1]) + IM(t2);

                RE(c3) = MUL_F((RE(cc[ac]) - RE(cc[ac+1])), taui);
                IM(c3) = MUL_F((IM(cc[ac]) - IM(cc[ac+1])), taui);

                RE(ch[ah+l1]) = RE(c2) + IM(c3);
                IM(ch[ah+l1]) = IM(c2) - RE(c3);
                RE(ch[ah+2*l1]) = RE(c2) - IM(c3);
                IM(ch[ah+2*l1]) = IM(c2) + RE(c3);
            }
        }
    } else {
        if (isign == 1)
        {
            for (k = 0; k < l1; k++)
            {
                for (i = 0; i < ido; i++)
                {
                    ac = i + (3*k+1)*ido;
                    ah = i + k * ido;

                    RE(t2) = RE(cc[ac]) + RE(cc[ac+ido]);
                    RE(c2) = RE(cc[ac-ido]) + MUL_F(RE(t2),taur);
                    IM(t2) = IM(cc[ac]) + IM(cc[ac+ido]);
                    IM(c2) = IM(cc[ac-ido]) + MUL_F(IM(t2),taur);

                    RE(ch[ah]) = RE(cc[ac-ido]) + RE(t2);
                    IM(ch[ah]) = IM(cc[ac-ido]) + IM(t2);

                    RE(c3) = MUL_F((RE(cc[ac]) - RE(cc[ac+ido])), taui);
                    IM(c3) = MUL_F((IM(cc[ac]) - IM(cc[ac+ido])), taui);

                    RE(d2) = RE(c2) - IM(c3);
                    IM(d3) = IM(c2) - RE(c3);
                    RE(d3) = RE(c2) + IM(c3);
                    IM(d2) = IM(c2) + RE(c3);

#if 1
                    ComplexMult(&IM(ch[ah+l1*ido]), &RE(ch[ah+l1*ido]),
                        IM(d2), RE(d2), RE(wa1[i]), IM(wa1[i]));
                    ComplexMult(&IM(ch[ah+2*l1*ido]), &RE(ch[ah+2*l1*ido]),
                        IM(d3), RE(d3), RE(wa2[i]), IM(wa2[i]));
#else
                    ComplexMult(&RE(ch[ah+l1*ido]), &IM(ch[ah+l1*ido]),
                        RE(d2), IM(d2), RE(wa1[i]), IM(wa1[i]));
                    ComplexMult(&RE(ch[ah+2*l1*ido]), &IM(ch[ah+2*l1*ido]),
                        RE(d3), IM(d3), RE(wa2[i]), IM(wa2[i]));
#endif
                }
            }
        } else {
            for (k = 0; k < l1; k++)
            {
                for (i = 0; i < ido; i++)
                {
                    ac = i + (3*k+1)*ido;
                    ah = i + k * ido;

                    RE(t2) = RE(cc[ac]) + RE(cc[ac+ido]);
                    RE(c2) = RE(cc[ac-ido]) + MUL_F(RE(t2),taur);
                    IM(t2) = IM(cc[ac]) + IM(cc[ac+ido]);
                    IM(c2) = IM(cc[ac-ido]) + MUL_F(IM(t2),taur);

                    RE(ch[ah]) = RE(cc[ac-ido]) + RE(t2);
                    IM(ch[ah]) = IM(cc[ac-ido]) + IM(t2);

                    RE(c3) = MUL_F((RE(cc[ac]) - RE(cc[ac+ido])), taui);
                    IM(c3) = MUL_F((IM(cc[ac]) - IM(cc[ac+ido])), taui);

                    RE(d2) = RE(c2) + IM(c3);
                    IM(d3) = IM(c2) + RE(c3);
                    RE(d3) = RE(c2) - IM(c3);
                    IM(d2) = IM(c2) - RE(c3);

#if 1
                    ComplexMult(&RE(ch[ah+l1*ido]), &IM(ch[ah+l1*ido]),
                        RE(d2), IM(d2), RE(wa1[i]), IM(wa1[i]));
                    ComplexMult(&RE(ch[ah+2*l1*ido]), &IM(ch[ah+2*l1*ido]),
                        RE(d3), IM(d3), RE(wa2[i]), IM(wa2[i]));
#else
                    ComplexMult(&IM(ch[ah+l1*ido]), &RE(ch[ah+l1*ido]),
                        IM(d2), RE(d2), RE(wa1[i]), IM(wa1[i]));
                    ComplexMult(&IM(ch[ah+2*l1*ido]), &RE(ch[ah+2*l1*ido]),
                        IM(d3), RE(d3), RE(wa2[i]), IM(wa2[i]));
#endif
                }
            }
        }
    }
}