Ejemplo n.º 1
0
static void test_scavenge(void) {
  gpr_log(GPR_INFO, "** test_scavenge **");
  grpc_resource_quota *q = grpc_resource_quota_create("test_scavenge");
  grpc_resource_quota_resize(q, 1024);
  grpc_resource_user *usr1 = grpc_resource_user_create(q, "usr1");
  grpc_resource_user *usr2 = grpc_resource_user_create(q, "usr2");
  {
    bool done = false;
    grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
    grpc_resource_user_alloc(&exec_ctx, usr1, 1024, set_bool(&done));
    grpc_exec_ctx_finish(&exec_ctx);
    GPR_ASSERT(done);
  }
  {
    grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
    grpc_resource_user_free(&exec_ctx, usr1, 1024);
    grpc_exec_ctx_finish(&exec_ctx);
  }
  {
    bool done = false;
    grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
    grpc_resource_user_alloc(&exec_ctx, usr2, 1024, set_bool(&done));
    grpc_exec_ctx_finish(&exec_ctx);
    GPR_ASSERT(done);
  }
  {
    grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
    grpc_resource_user_free(&exec_ctx, usr2, 1024);
    grpc_exec_ctx_finish(&exec_ctx);
  }
  grpc_resource_quota_unref(q);
  destroy_user(usr1);
  destroy_user(usr2);
}
Ejemplo n.º 2
0
void test_state_is_reset_when_if_fails2()
{
    // Similar to test_state_is_reset_when_if_fails, but this one doesn't
    // have an 'else' block and it uses test_oracle.
    
    internal_debug_function::oracle_clear();

    Branch branch;
    Term* a = branch.compile("a = true");
    
    branch.compile("if a { state s = test_oracle() }");

    internal_debug_function::oracle_send(1);
    internal_debug_function::oracle_send(2);
    internal_debug_function::oracle_send(3);

    Stack context;
    evaluate_branch(&context, &branch);
    test_equals(&context.state, "{_if_block: [{s: 1}]}");

    evaluate_branch(&context, &branch);
    test_equals(&context.state, "{_if_block: [{s: 1}]}");

    set_bool(a, false);
    evaluate_branch(&context, &branch);
    test_equals(&context.state, "{_if_block: [null, null]}");

    set_bool(a, true);
    evaluate_branch(&context, &branch);
    test_equals(&context.state, "{_if_block: [{s: 2}]}");
}
Ejemplo n.º 3
0
static void test_unused_reclaim_is_cancelled(void) {
  gpr_log(GPR_INFO, "** test_unused_reclaim_is_cancelled **");
  grpc_resource_quota *q =
      grpc_resource_quota_create("test_unused_reclaim_is_cancelled");
  grpc_resource_quota_resize(q, 1024);
  grpc_resource_user usr;
  grpc_resource_user_init(&usr, q, "usr");
  bool benign_done = false;
  bool destructive_done = false;
  {
    grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
    grpc_resource_user_post_reclaimer(
        &exec_ctx, &usr, false, make_unused_reclaimer(set_bool(&benign_done)));
    grpc_resource_user_post_reclaimer(
        &exec_ctx, &usr, true,
        make_unused_reclaimer(set_bool(&destructive_done)));
    grpc_exec_ctx_finish(&exec_ctx);
    GPR_ASSERT(!benign_done);
    GPR_ASSERT(!destructive_done);
  }
  grpc_resource_quota_unref(q);
  destroy_user(&usr);
  GPR_ASSERT(benign_done);
  GPR_ASSERT(destructive_done);
}
Ejemplo n.º 4
0
void test_state_is_reset_when_if_fails()
{
    Branch branch;
    Stack context;

    Term* c = branch.compile("c = true");
    branch.compile("if c { state i = 0; i += 1 } else { 'hi' }");

    evaluate_branch(&context, &branch);
    test_equals(&context.state, "{_if_block: [{i: 1}]}");

    evaluate_branch(&context, &branch);
    test_equals(&context.state, "{_if_block: [{i: 2}]}");

    evaluate_branch(&context, &branch);
    test_equals(&context.state, "{_if_block: [{i: 3}]}");

    set_bool(c, false);

    evaluate_branch(&context, &branch);
    test_equals(&context.state, "{_if_block: [null, null]}");

    set_bool(c, true);

    evaluate_branch(&context, &branch);
    test_equals(&context.state, "{_if_block: [{i: 1}]}");
}
Ejemplo n.º 5
0
gboolean mpris_tracklist_get_metadata(MprisTrackList * obj, gint pos, GHashTable * *metadata, GError * *error)
{
    struct MprisMetadataRequest request = {.playlist = -1,.entry = pos };

    get_mpris_metadata(&request);
    *metadata = request.metadata;
    return TRUE;
}

gboolean mpris_tracklist_get_current_track(MprisTrackList * obj, gint * pos, GError * *error)
{
    struct PositionRequest request = {.playlist = -1,.entry = -1 };

    get_position(&request);
    *pos = request.entry;
    return TRUE;
}

gboolean mpris_tracklist_get_length(MprisTrackList * obj, gint * length, GError * *error)
{
    struct PositionRequest request = {.playlist = -1,.entry = -1 };

    get_position(&request);
    *length = request.entry_count;
    return TRUE;
}

gboolean mpris_tracklist_add_track(MprisTrackList * obj, gchar * uri, gboolean play, GError * *error)
{
    struct AddRequest *request = g_malloc(sizeof(struct AddRequest));

    request->position = -1;
    request->filename = g_strdup(uri);
    request->play = play;

    g_timeout_add(0, add_cb, request);
    return TRUE;
}

gboolean mpris_tracklist_del_track(MprisTrackList * obj, gint pos, GError * *error)
{
    g_timeout_add(0, delete_cb, GINT_TO_POINTER(pos));
    return TRUE;
}

gboolean mpris_tracklist_loop (MprisTrackList * obj, gboolean loop, GError * *
 error)
{
    set_bool (NULL, "repeat", loop);
    return TRUE;
}

gboolean mpris_tracklist_random (MprisTrackList * obj, gboolean random,
 GError * * error)
{
    set_bool (NULL, "shuffle", random);
    return TRUE;
}
Ejemplo n.º 6
0
static void
test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released(
    void) {
  gpr_log(GPR_INFO,
          "** "
          "test_resource_user_stays_allocated_and_reclaimers_unrun_until_"
          "memory_released **");
  grpc_resource_quota *q = grpc_resource_quota_create(
      "test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_"
      "released");
  grpc_resource_quota_resize(q, 1024);
  for (int i = 0; i < 10; i++) {
    grpc_resource_user usr;
    grpc_resource_user_init(&usr, q, "usr");
    bool done = false;
    bool reclaimer_cancelled = false;
    {
      grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
      grpc_resource_user_post_reclaimer(
          &exec_ctx, &usr, false,
          make_unused_reclaimer(set_bool(&reclaimer_cancelled)));
      grpc_exec_ctx_finish(&exec_ctx);
      GPR_ASSERT(!reclaimer_cancelled);
    }
    {
      bool allocated = false;
      grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
      grpc_resource_user_alloc(&exec_ctx, &usr, 1024, set_bool(&allocated));
      grpc_exec_ctx_finish(&exec_ctx);
      GPR_ASSERT(allocated);
      GPR_ASSERT(!reclaimer_cancelled);
    }
    {
      grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
      grpc_resource_user_shutdown(&exec_ctx, &usr, set_bool(&done));
      grpc_exec_ctx_finish(&exec_ctx);
      GPR_ASSERT(!done);
      GPR_ASSERT(!reclaimer_cancelled);
    }
    {
      grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
      grpc_resource_user_free(&exec_ctx, &usr, 1024);
      grpc_exec_ctx_finish(&exec_ctx);
      GPR_ASSERT(done);
      GPR_ASSERT(reclaimer_cancelled);
    }
    {
      grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
      grpc_resource_user_destroy(&exec_ctx, &usr);
      grpc_exec_ctx_finish(&exec_ctx);
    }
  }
  grpc_resource_quota_unref(q);
}
void add_arg(node_ptr var, node_ptr qstring, int isbool)
{
    if (!var || !qstring) {
	yyerror("Null node");
	return;
    }
    add_symbol(var, qstring);
    if (isbool) {
	set_bool(var);
	set_bool(qstring);
    }
}
Ejemplo n.º 8
0
void context_params::set(char const * param, char const * value) {
    std::string p = param;
    unsigned n = static_cast<unsigned>(p.size());
    for (unsigned i = 0; i < n; i++) {
        if (p[i] >= 'A' && p[i] <= 'Z')
            p[i] = p[i] - 'A' + 'a';
        else if (p[i] == '-')
            p[i] = '_';
    }
    if (p == "timeout") {
        long val = strtol(value, 0, 10);
        m_timeout = static_cast<unsigned>(val);
    }
    else if (p == "type_check" || p == "well_sorted_check") {
        set_bool(m_well_sorted_check, param, value);
    }
    else if (p == "auto_config") {
        set_bool(m_auto_config, param, value);
    }
    else if (p == "proof") {
        set_bool(m_proof, param, value);
    }
    else if (p == "model") {
        set_bool(m_model, param, value);
    }
    else if (p == "model_validate") {
        set_bool(m_model_validate, param, value);
    }
    else if (p == "trace") {
        set_bool(m_trace, param, value);
    }
    else if (p == "trace_file_name") {
        m_trace_file_name = value;
    }
    else if (p == "unsat_core") {
        set_bool(m_unsat_core, param, value);
    }
    else if (p == "debug_ref_count") {
        set_bool(m_debug_ref_count, param, value);
    }
    else if (p == "smtlib2_compliant") {
        set_bool(m_smtlib2_compliant, param, value);
    }
    else {
       param_descrs d;
       collect_param_descrs(d);
       std::stringstream strm;
       strm << "unknown parameter '" << p << "'\n";
       strm << "Legal parameters are:\n";
       d.display(strm, 2, false, false);
       throw default_exception(strm.str());        
    }
}
Ejemplo n.º 9
0
const void *exec_internal_broam(
    const char *arg,
    const struct cfgmenu *menu_root,
    const struct cfgmenu **p_menu,
    const struct cfgmenu**p_item)
{
    const void *v = NULL;
    *p_item = find_cfg_item(arg, menu_root, p_menu);
    if (NULL == *p_item)
        return v;

    v = (*p_item)->pvalue;
    if (v) {
        // scan for a possible argument to the command
        while (!IS_SPC(*arg))
            ++arg;
        skip_spc(&arg);
        // now set the appropriate variable
        if (is_fixed_string(v)) {
            strcpy((char *)v, arg);
        } else if (is_string_item(v)) {
            strcpy((char *)v, arg);
        } else if (get_int_item(v)) {
            if (*arg) *(int*)v = atoi(arg);
        } else {
            set_bool((bool*)v, arg);
        }
        // write to blackbox.rc or extensions.rc (automatic)
        Settings_WriteRCSetting(v);
    }
    return v;
}
Ejemplo n.º 10
0
void Term__is_value(VM* vm)
{
    Term* t = as_term_ref(vm->input(0));

    bool consideredValue = is_value(t) || t->function == FUNCS.require;
    set_bool(vm->output(), consideredValue);
}
Ejemplo n.º 11
0
void Block__has_static_error(VM* vm)
{
    Block* block = as_block(vm->input(0));
    if (block == NULL)
        return vm->throw_str("NULL block");
    set_bool(vm->output(), has_static_errors_cached(block));
}
Ejemplo n.º 12
0
void list_names_that_must_be_looped(Block* contents, Value* names)
{
    // Find all names within 'contents' that must be looped. A name must be looped when
    // a term inside the loop binds a name that was already used outside the loop.

    Value namesMap;
    set_hashtable(&namesMap);

    for (BlockIteratorFlat it(contents); it; ++it) {
        Term* term = it.current();

        if (has_empty_name(term))
            continue;

        Value termVal;
        termVal.set_term(contents->owningTerm);
        Term* outsideName = find_name_at(&termVal, term_name(term));

        // Don't look at names outside the major block.
        if (outsideName != NULL && !is_under_same_major_block(term, outsideName))
            outsideName = NULL;

        if (outsideName != NULL)
            set_bool(hashtable_insert(&namesMap, term_name(term)), true);
    }

    hashtable_get_keys(&namesMap, names);
    list_sort(names, NULL, NULL);
}
Ejemplo n.º 13
0
static bool backlight_on_when_charging(void)
{
    bool result = set_bool(str(LANG_BACKLIGHT_ON_WHEN_CHARGING),
                           &global_settings.backlight_on_when_charging);
    backlight_set_on_when_charging(global_settings.backlight_on_when_charging);
    return result;
}
Ejemplo n.º 14
0
static void test_resource_user_stays_allocated_until_memory_released(void) {
  gpr_log(GPR_INFO,
          "** test_resource_user_stays_allocated_until_memory_released **");
  grpc_resource_quota *q = grpc_resource_quota_create(
      "test_resource_user_stays_allocated_until_memory_released");
  grpc_resource_quota_resize(q, 1024 * 1024);
  grpc_resource_user usr;
  grpc_resource_user_init(&usr, q, "usr");
  bool done = false;
  {
    grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
    grpc_resource_user_alloc(&exec_ctx, &usr, 1024, NULL);
    grpc_exec_ctx_finish(&exec_ctx);
  }
  {
    grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
    grpc_resource_quota_unref(q);
    grpc_resource_user_shutdown(&exec_ctx, &usr, set_bool(&done));
    grpc_exec_ctx_finish(&exec_ctx);
    GPR_ASSERT(!done);
  }
  {
    grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
    grpc_resource_user_free(&exec_ctx, &usr, 1024);
    grpc_exec_ctx_finish(&exec_ctx);
    GPR_ASSERT(done);
  }
  {
    grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
    grpc_resource_user_destroy(&exec_ctx, &usr);
    grpc_exec_ctx_finish(&exec_ctx);
  }
}
Ejemplo n.º 15
0
void block_set_evaluation_empty(Block* block, bool empty)
{
    if (empty)
        set_bool(block_insert_property(block, s_EvaluationEmpty), true);
    else
        block_remove_property(block, s_EvaluationEmpty);
}
Ejemplo n.º 16
0
void block_set_has_effects(Block* block, bool hasEffects)
{
    if (hasEffects)
        set_bool(block_insert_property(block, s_HasEffects), true);
    else
        block_remove_property(block, s_HasEffects);
}
Ejemplo n.º 17
0
static void
moo_action_base_set_dead (MooActionBase *ab, gboolean dead)
{
    g_return_if_fail (MOO_IS_ACTION_BASE (ab));
    set_bool (ab, "moo-action-dead", dead);
    g_object_notify (G_OBJECT (ab), "dead");
}
Ejemplo n.º 18
0
static bool caption_backlight(void)
{
    bool rc = set_bool( str(LANG_CAPTION_BACKLIGHT),
                        &global_settings.caption_backlight);

    return rc;
}
Ejemplo n.º 19
0
	value& value::operator=(const value& aOther) {
		switch (aOther.mType)
		{
		case CHAR_T:
			set_char(aOther.mChar);
			break;
		case BOOL_T:
			set_bool(aOther.mBool);
			break;
		case UNSIGNED_T:
			set_unsigned(aOther.mUnsigned);
			break;
		case SIGNED_T:
			set_signed(aOther.mSigned);
			break;
		case FLOAT_T:
			set_float(aOther.mFloat);
			break;
		case POINTER_T:
			set_pointer(aOther.mPointer);
			break;
		case STRING_T:
			set_string(*static_cast<const c_string*>(aOther.mPointer));
			break;
		case ARRAY_T:
			set_array(*static_cast<const container<value>*>(aOther.mPointer));
			break;
		case OBJECT_T:
			set_object(*static_cast<const std::map<c_string, value>*>(aOther.mPointer));
			break;
		default:
			break;
		}
		return *this;
	}
Ejemplo n.º 20
0
static void
moo_action_base_set_has_submenu (MooActionBase *ab, gboolean has_submenu)
{
    g_return_if_fail (MOO_IS_ACTION_BASE (ab));
    set_bool (ab, "moo-action-has-submenu", has_submenu);
    g_object_notify (G_OBJECT (ab), "has-submenu");
}
Ejemplo n.º 21
0
static void test_multiple_reclaims_can_be_triggered(void) {
  gpr_log(GPR_INFO, "** test_multiple_reclaims_can_be_triggered **");
  grpc_resource_quota *q =
      grpc_resource_quota_create("test_multiple_reclaims_can_be_triggered");
  grpc_resource_quota_resize(q, 1024);
  grpc_resource_user usr;
  grpc_resource_user_init(&usr, q, "usr");
  bool benign_done = false;
  bool destructive_done = false;
  {
    bool done = false;
    grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
    grpc_resource_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
    grpc_exec_ctx_finish(&exec_ctx);
    GPR_ASSERT(done);
  }
  {
    grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
    grpc_resource_user_post_reclaimer(
        &exec_ctx, &usr, false,
        make_reclaimer(&usr, 512, set_bool(&benign_done)));
    grpc_resource_user_post_reclaimer(
        &exec_ctx, &usr, true,
        make_reclaimer(&usr, 512, set_bool(&destructive_done)));
    grpc_exec_ctx_finish(&exec_ctx);
    GPR_ASSERT(!benign_done);
    GPR_ASSERT(!destructive_done);
  }
  {
    bool done = false;
    grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
    grpc_resource_user_alloc(&exec_ctx, &usr, 1024, set_bool(&done));
    grpc_exec_ctx_finish(&exec_ctx);
    GPR_ASSERT(benign_done);
    GPR_ASSERT(destructive_done);
    GPR_ASSERT(done);
  }
  {
    grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
    grpc_resource_user_free(&exec_ctx, &usr, 1024);
    grpc_exec_ctx_finish(&exec_ctx);
  }
  grpc_resource_quota_unref(q);
  destroy_user(&usr);
  GPR_ASSERT(benign_done);
  GPR_ASSERT(destructive_done);
}
Ejemplo n.º 22
0
static bool replaygain(void)
{
    bool result = set_bool(str(LANG_REPLAYGAIN_ENABLE), 
        &global_settings.replaygain);
        
    dsp_set_replaygain(true);
    return result;
}
Ejemplo n.º 23
0
static void
moo_action_base_set_force_accel_label (MooActionBase *ab,
                                       gboolean       force)
{
    g_return_if_fail (MOO_IS_ACTION_BASE (ab));
    set_bool (ab, "moo-action-force-accel-label", force);
    g_object_notify (G_OBJECT (ab), "force-accel-label");
}
Ejemplo n.º 24
0
static void
moo_action_base_set_accel_editable (gpointer action,
                                    gboolean editable)
{
    g_return_if_fail (MOO_IS_ACTION_BASE (action));
    set_bool (action, "moo-action-accel-editable", editable);
    g_object_notify (G_OBJECT (action), "accel-editable");
}
Ejemplo n.º 25
0
static void
moo_action_base_set_connect_accel (gpointer action,
                                   gboolean connect)
{
    g_return_if_fail (MOO_IS_ACTION_BASE (action));
    set_bool (action, "moo-action-connect-accel", connect);
    g_object_notify (G_OBJECT (action), "connect-accel");
}
Ejemplo n.º 26
0
void
_moo_action_set_no_accel (gpointer action,
                          gboolean no_accel)
{
    g_return_if_fail (MOO_IS_ACTION_BASE (action));
    set_bool (action, "moo-action-no-accel", no_accel);
    g_object_notify (G_OBJECT (action), "no-accel");
}
Ejemplo n.º 27
0
void assign(caValue* value, int handle)
{
    test_assert(!as_bool(g_slots[handle]));
    set_bool(g_slots[handle], true);
    caValue userdata;
    set_int(&userdata, handle);
    handle_t::set(value, &handle_type, &userdata);
}
Ejemplo n.º 28
0
int colvarparse::_get_keyval_scalar_novalue_(std::string const &key_str,
                                             bool &value,
                                             Parse_Mode const &parse_mode)
{
  set_bool(reinterpret_cast<void *>(&value), true);
  mark_key_set_user<bool>(key_str, value, parse_mode);
  return COLVARS_OK;
}
Ejemplo n.º 29
0
static bool replaygain_noclip(void)
{
    bool result = set_bool(str(LANG_REPLAYGAIN_NOCLIP), 
        &global_settings.replaygain_noclip);

    dsp_set_replaygain(true);
    return result;
}
Ejemplo n.º 30
0
static void destroy_user(grpc_resource_user *usr) {
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
  bool done = false;
  grpc_resource_user_shutdown(&exec_ctx, usr, set_bool(&done));
  grpc_exec_ctx_flush(&exec_ctx);
  GPR_ASSERT(done);
  grpc_resource_user_destroy(&exec_ctx, usr);
  grpc_exec_ctx_finish(&exec_ctx);
}