// two transactions with two transaction items -> $reason
void
TransactionItemReasonTest::test_TwoTransactions_TwoTransactionItems()
{
    Swdb swdb(conn);

    {
        swdb.initTransaction();

        auto rpm_bash = std::make_shared< RPMItem >(conn);
        rpm_bash->setName("bash");
        rpm_bash->setEpoch(0);
        rpm_bash->setVersion("4.4.12");
        rpm_bash->setRelease("5.fc26");
        rpm_bash->setArch("x86_64");
        std::string repoid = "base";
        TransactionItemAction action = TransactionItemAction::INSTALL;
        TransactionItemReason reason = TransactionItemReason::GROUP;
        swdb.addItem(rpm_bash, repoid, action, reason);

        swdb.beginTransaction(1, "", "", 0);
        swdb.endTransaction(2, "", true);
    }

    {
        swdb.initTransaction();

        auto rpm_bash = std::make_shared< RPMItem >(conn);
        rpm_bash->setName("bash");
        rpm_bash->setEpoch(0);
        rpm_bash->setVersion("4.4.12");
        rpm_bash->setRelease("5.fc26");
        rpm_bash->setArch("i686");
        std::string repoid = "base";
        TransactionItemAction action = TransactionItemAction::INSTALL;
        TransactionItemReason reason = TransactionItemReason::USER;
        swdb.addItem(rpm_bash, repoid, action, reason);

        swdb.beginTransaction(1, "", "", 0);
        swdb.endTransaction(2, "", true);
    }

    // package exists -> $reason
    CPPUNIT_ASSERT_EQUAL(static_cast< TransactionItemReason >(
                             swdb.resolveRPMTransactionItemReason("bash", "x86_64", -1)),
                         TransactionItemReason::GROUP);

    // package exists -> $reason
    CPPUNIT_ASSERT_EQUAL(static_cast< TransactionItemReason >(
                             swdb.resolveRPMTransactionItemReason("bash", "i686", -1)),
                         TransactionItemReason::USER);

    // 2 packages exists, arch not specified -> return best $reason
    CPPUNIT_ASSERT_EQUAL(
        static_cast< TransactionItemReason >(swdb.resolveRPMTransactionItemReason("bash", "", -1)),
        TransactionItemReason::USER);
}
Example #2
0
static MergedTransactionPtr
prepareMergedTransaction(SQLite3Ptr conn,
                         TransactionItemAction actionFirst,
                         TransactionItemAction actionSecond,
                         const std::string &versionFirst,
                         const std::string &versionSecond,
                         TransactionItemAction oldFirstAction = TransactionItemAction::INSTALL,
                         const std::string &oldFirstVersion = {}

)
{
    auto firstRPM = std::make_shared< RPMItem >(conn);
    firstRPM->setName("foo");
    firstRPM->setEpoch(0);
    firstRPM->setVersion(versionFirst);
    firstRPM->setRelease("2.fc26");
    firstRPM->setArch("x86_64");
    firstRPM->save();

    auto secondRPM = std::make_shared< RPMItem >(conn);
    secondRPM->setName("foo");
    secondRPM->setEpoch(0);
    secondRPM->setVersion(versionSecond);
    secondRPM->setRelease("2.fc26");
    secondRPM->setArch("x86_64");
    secondRPM->save();

    auto first = initTransFirst(conn);
    if (oldFirstAction != TransactionItemAction::INSTALL) {
        auto oldFirst = std::make_shared< RPMItem >(conn);
        oldFirst->setName("foo");
        oldFirst->setEpoch(0);
        oldFirst->setVersion(oldFirstVersion);
        oldFirst->setRelease("2.fc26");
        oldFirst->setArch("x86_64");
        oldFirst->save();
        first->addItem(oldFirst, "base", oldFirstAction, TransactionItemReason::USER);
    }

    first->addItem(firstRPM, "base", actionFirst, TransactionItemReason::USER);
    first->begin();
    first->finish(true);

    auto second = initTransSecond(conn);
    second->addItem(secondRPM, "base", actionSecond, TransactionItemReason::USER);
    second->begin();
    second->finish(true);

    auto merged = std::make_shared< MergedTransaction >(first);
    merged->merge(second);
    return merged;
}
Example #3
0
bool Rjp1::executeSongSequenceOp(Rjp1Channel *channel, uint8 code, const uint8 *&p) {
	bool loop = true;
	const uint8 *offs;
	switch (code & 7) {
	case 0:
		offs = channel->sequenceOffsets;
		channel->loopSeq2Count = 1;
		while (1) {
			code = *offs++;
			if (code != 0) {
				channel->sequenceOffsets = offs;
				p = READ_BE_UINT32(_vars.songData[4] + code * 4) + _vars.songData[6];
				break;
			} else {
				code = offs[0];
				if (code == 0) {
					p = 0;
					channel->active = false;
					_vars.activeChannelsMask &= ~(1 << _vars.currentChannel);
					loop = false;
					break;
				} else if (code & 0x80) {
					code = offs[1];
					offs = READ_BE_UINT32(_vars.songData[3] + code * 4) + _vars.songData[5];
				} else {
					offs -= code;
				}
			}
		}
		break;
	case 1:
		setRelease(channel);
		loop = false;
		break;
	case 2:
		channel->loopSeqCount = *p++;
		break;
	case 3:
		channel->loopSeq2Count = *p++;
		break;
	case 4:
		code = *p++;
		if (code != 0) {
			setupInstrument(channel, code);
		}
		break;
	case 5:
		channel->volumeScale = *p++;
		break;
	case 6:
		channel->freqStep = *p++;
		channel->freqInc = READ_BE_UINT32(p); p += 4;
		channel->freqInit = 0;
		break;
	case 7:
		loop = false;
		break;
	}
	return loop;
}
Example #4
0
bool Rjp1::executeSfxSequenceOp(Rjp1Channel *channel, uint8 code, const uint8 *&p) {
	bool loop = true;
	switch (code & 7) {
	case 0:
		_vars.activeChannelsMask &= ~(1 << _vars.currentChannel);
		loop = false;
		stopPaula();
		break;
	case 1:
		setRelease(channel);
		loop = false;
		break;
	case 2:
		channel->loopSeqCount = *p++;
		break;
	case 3:
		channel->loopSeq2Count = *p++;
		break;
	case 4:
		code = *p++;
		if (code != 0) {
			setupInstrument(channel, code);
		}
		break;
	case 7:
		loop = false;
		break;
	}
	return loop;
}
Example #5
0
void initADSR(struct ADSR* adsr, unsigned a, unsigned d, float s, unsigned r){
	setSustain(adsr, s);
	setAttack(adsr, a);
	setDecay(adsr, d);
	setRelease(adsr, r);
	adsr->index = 0;
	adsr->level = 0.00000000001f;
}
Example #6
0
LimiterImpl::LimiterImpl(int sampleRate) {

    sampleRate = MAX(sampleRate, 8000);
    sampleRate = MIN(sampleRate, 96000);
    _sampleRate = sampleRate;

    // defaults
    setThreshold(0.0f);
    setRelease(250.0f);
}
Example #7
0
void Compressor::setNValue(int idx, double value)
      {
      switch (idx) {
            case RMS_PEAK:  setRmsPeak(value);    break;
            case ATTACK:    setAttack(value);     break;
            case RELEASE:   setRelease(value);    break;
            case THRESHOLD: setThreshold(value);  break;
            case RATIO:     setRatio(value);      break;
            case KNEE:      setKnee(value);       break;
            case GAIN:      setMakeupGain(value); break;
            }
      }
Example #8
0
static RPMItemPtr
nevraToRPMItem(SQLite3Ptr conn, std::string nevra)
{
    auto nevraObject = new Nevra;
    if (hy_nevra_possibility(nevra.c_str(), HY_FORM_NEVRA, nevraObject)) {
        return nullptr;
    }
    if (nevraObject->getEpoch() < 0) {
        nevraObject->setEpoch(0);
    }

    auto rpm = std::make_shared< RPMItem >(conn);
    rpm->setName(nevraObject->getName());
    rpm->setEpoch(nevraObject->getEpoch());
    rpm->setVersion(nevraObject->getVersion());
    rpm->setRelease(nevraObject->getRelease());
    rpm->setArch(nevraObject->getArch());
    return rpm;
}
Example #9
0
static SwdbPrivate::TransactionPtr
initTransSecond(SQLite3Ptr conn)
{
    // create the second transaction
    auto second = std::make_shared< SwdbPrivate::Transaction >(conn);
    second->setDtBegin(3);
    second->setDtEnd(4);
    second->setRpmdbVersionBegin("begin 2");
    second->setRpmdbVersionEnd("end 2");
    second->setUserId(1001);
    second->setCmdline("dnf install bar");

    auto rpmRpm = std::make_shared< RPMItem >(conn);
    rpmRpm->setName("rpm");
    rpmRpm->setEpoch(0);
    rpmRpm->setVersion("4.14.0");
    rpmRpm->setRelease("2.fc26");
    rpmRpm->setArch("x86_64");
    rpmRpm->save();

    second->addSoftwarePerformedWith(rpmRpm);
    return second;
}
Example #10
0
static SwdbPrivate::TransactionPtr
initTransFirst(SQLite3Ptr conn)
{
    // create the first transaction
    auto first = std::make_shared< SwdbPrivate::Transaction >(conn);
    first->setDtBegin(1);
    first->setDtEnd(2);
    first->setRpmdbVersionBegin("begin 1");
    first->setRpmdbVersionEnd("end 1");
    first->setUserId(1000);
    first->setCmdline("dnf install foo");

    auto dnfRpm = std::make_shared< RPMItem >(conn);
    dnfRpm->setName("dnf");
    dnfRpm->setEpoch(0);
    dnfRpm->setVersion("3.0.0");
    dnfRpm->setRelease("2.fc26");
    dnfRpm->setArch("x86_64");
    dnfRpm->save();

    first->addSoftwarePerformedWith(dnfRpm);
    return first;
}
// one FAILED transaction with one transaction item -> $reason
void
TransactionItemReasonTest::test_OneFailedTransaction_OneTransactionItem()
{
    Swdb swdb(conn);

    swdb.initTransaction();

    auto rpm_bash = std::make_shared< RPMItem >(conn);
    rpm_bash->setName("bash");
    rpm_bash->setEpoch(0);
    rpm_bash->setVersion("4.4.12");
    rpm_bash->setRelease("5.fc26");
    rpm_bash->setArch("x86_64");
    std::string repoid = "base";
    TransactionItemAction action = TransactionItemAction::INSTALL;
    TransactionItemReason reason = TransactionItemReason::GROUP;
    swdb.addItem(rpm_bash, repoid, action, reason);

    swdb.beginTransaction(1, "", "", 0);
    swdb.endTransaction(2, "", false);

    // failed transaction -> UNKNOWN
    CPPUNIT_ASSERT_EQUAL(static_cast< TransactionItemReason >(
                             swdb.resolveRPMTransactionItemReason("bash", "x86_64", -1)),
                         TransactionItemReason::UNKNOWN);

    // failed transaction -> UNKNOWN
    CPPUNIT_ASSERT_EQUAL(static_cast< TransactionItemReason >(
                             swdb.resolveRPMTransactionItemReason("bash", "i686", -1)),
                         TransactionItemReason::UNKNOWN);

    // failed transaction -> UNKNOWN
    CPPUNIT_ASSERT_EQUAL(
        static_cast< TransactionItemReason >(swdb.resolveRPMTransactionItemReason("bash", "", -1)),
        TransactionItemReason::UNKNOWN);
}
Example #12
0
//==============================================================================
ADSRComponent::ADSRComponent ()
{
    addAndMakeVisible (attackSlider = new Slider ("Attack slider"));
    attackSlider->setTooltip (TRANS("Attack"));
    attackSlider->setRange (5, 15000, 0);
    attackSlider->setSliderStyle (Slider::LinearVertical);
    attackSlider->setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20);
    attackSlider->addListener (this);
    attackSlider->setSkewFactor (0.4);

    addAndMakeVisible (decaySlider = new Slider (String::empty));
    decaySlider->setTooltip (TRANS("Decay"));
    decaySlider->setRange (5, 15000, 0);
    decaySlider->setSliderStyle (Slider::LinearVertical);
    decaySlider->setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20);
    decaySlider->addListener (this);
    decaySlider->setSkewFactor (0.4);

    addAndMakeVisible (sustainSlider = new Slider (String::empty));
    sustainSlider->setTooltip (TRANS("Sustain"));
    sustainSlider->setRange (0, 1, 0);
    sustainSlider->setSliderStyle (Slider::LinearVertical);
    sustainSlider->setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20);
    sustainSlider->addListener (this);

    addAndMakeVisible (releaseSlider = new Slider (String::empty));
    releaseSlider->setTooltip (TRANS("Release"));
    releaseSlider->setRange (5, 15000, 0);
    releaseSlider->setSliderStyle (Slider::LinearVertical);
    releaseSlider->setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20);
    releaseSlider->addListener (this);
    releaseSlider->setSkewFactor (0.4);

    addAndMakeVisible (attackLabel = new Label (String::empty,
                                                TRANS("A")));
    attackLabel->setFont (Font (15.00f, Font::bold));
    attackLabel->setJustificationType (Justification::centred);
    attackLabel->setEditable (false, false, false);
    attackLabel->setColour (TextEditor::textColourId, Colours::black);
    attackLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));

    addAndMakeVisible (decayLabel = new Label (String::empty,
                                               TRANS("D")));
    decayLabel->setFont (Font (15.00f, Font::bold));
    decayLabel->setJustificationType (Justification::centred);
    decayLabel->setEditable (false, false, false);
    decayLabel->setColour (TextEditor::textColourId, Colours::black);
    decayLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));

    addAndMakeVisible (sustainLabel = new Label (String::empty,
                                                 TRANS("S")));
    sustainLabel->setFont (Font (15.00f, Font::bold));
    sustainLabel->setJustificationType (Justification::centred);
    sustainLabel->setEditable (false, false, false);
    sustainLabel->setColour (TextEditor::textColourId, Colours::black);
    sustainLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));

    addAndMakeVisible (releaseLabel = new Label (String::empty,
                                                 TRANS("R")));
    releaseLabel->setFont (Font (15.00f, Font::bold));
    releaseLabel->setJustificationType (Justification::centred);
    releaseLabel->setEditable (false, false, false);
    releaseLabel->setColour (TextEditor::textColourId, Colours::black);
    releaseLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));


    //[UserPreSize]
    //[/UserPreSize]

    setSize (600, 400);


    //[Constructor] You can add your own custom stuff here..
    setAttack(5);
    setDecay(5);
    setSustain(1);
    setRelease(5);
    //[/Constructor]
}
Example #13
0
void
WorkflowTest::testDefaultWorkflow()
{
    // TODO: init/begin/end trans

    // STEP 1: create transaction object
    SwdbPrivate::Transaction trans(conn);
    CPPUNIT_ASSERT(trans.getDone() == false);

    // STEP 2: set vars
    trans.setReleasever("26");

    // populate goal
    // resolve dependencies
    // prepare RPM transaction

    // STEP 3: associate RPMs to the transaction
    // bash-4.4.12-5.fc26.x86_64
    auto rpm_bash = std::make_shared< RPMItem >(conn);
    rpm_bash->setName("bash");
    rpm_bash->setEpoch(0);
    rpm_bash->setVersion("4.4.12");
    rpm_bash->setRelease("5.fc26");
    rpm_bash->setArch("x86_64");
    std::string repoid = "base";
    TransactionItemAction action = TransactionItemAction::INSTALL;
    TransactionItemReason reason = TransactionItemReason::GROUP;
    trans.addItem(rpm_bash, repoid, action, reason);

    // systemd-233-6.fc26
    auto rpm_systemd = std::make_shared< RPMItem >(conn);
    rpm_systemd->setName("systemd");
    rpm_systemd->setEpoch(0);
    rpm_systemd->setVersion("233");
    rpm_systemd->setRelease("6.fc26");
    rpm_systemd->setArch("x86_64");
    repoid = "base";
    action = TransactionItemAction::OBSOLETE;
    reason = TransactionItemReason::USER;
    auto ti_rpm_systemd = trans.addItem(rpm_systemd, repoid, action, reason);

    // sysvinit-2.88-14.dsf.fc20
    auto rpm_sysvinit = std::make_shared< RPMItem >(conn);
    rpm_sysvinit->setName("sysvinit");
    rpm_sysvinit->setEpoch(0);
    rpm_sysvinit->setVersion("2.88");
    rpm_sysvinit->setRelease("14.dsf.fc20");
    rpm_sysvinit->setArch("x86_64");
    repoid = "f20";
    action = TransactionItemAction::OBSOLETED;
    reason = TransactionItemReason::USER;
    auto ti_rpm_sysvinit = trans.addItem(rpm_sysvinit, repoid, action, reason);
    ti_rpm_sysvinit->addReplacedBy(ti_rpm_systemd);

    auto comps_group_core = std::make_shared< CompsGroupItem >(conn);
    comps_group_core->setGroupId("core");
    comps_group_core->setName("Core");
    comps_group_core->setTranslatedName("Úplný základ");
    comps_group_core->addPackage("bash", true, CompsPackageType::MANDATORY);
    repoid = "";
    action = TransactionItemAction::INSTALL;
    reason = TransactionItemReason::USER;
    trans.addItem(comps_group_core, repoid, action, reason);

    auto comps_environment_minimal = std::make_shared< CompsEnvironmentItem >(conn);
    comps_environment_minimal->setEnvironmentId("minimal");
    comps_environment_minimal->setName("Minimal");
    comps_environment_minimal->setTranslatedName("mmm");
    comps_environment_minimal->addGroup("core", true, CompsPackageType::MANDATORY);
    repoid = "";
    action = TransactionItemAction::INSTALL;
    reason = TransactionItemReason::USER;
    trans.addItem(comps_environment_minimal, repoid, action, reason);

    // STEP 4: save transaction and all associated items
    trans.begin();

    // STEP 5: run RPM transaction; callback: mark completed items
    for (auto i : trans.getItems()) {
        i->setDone(true);
        i->save();
    }

    // STEP 6
    // mark completed transaction
    trans.finish(true);
    CPPUNIT_ASSERT(trans.getDone() == true);

    // VERIFY
    // verify that data is available via public API
    auto trans2 = libdnf::Transaction(conn, trans.getId());
    CPPUNIT_ASSERT(trans2.getDone() == true);

    CPPUNIT_ASSERT(trans2.getItems().size() == 5);

    for (auto i : trans2.getItems()) {
        if (i->getId() == 1) {
            CPPUNIT_ASSERT(i->getAction() == TransactionItemAction::INSTALL);
            CPPUNIT_ASSERT(i->getReason() == TransactionItemReason::GROUP);
            CPPUNIT_ASSERT(i->getRepoid() == "base");
        } else if (i->getId() == 2) {
            CPPUNIT_ASSERT(i->getAction() == TransactionItemAction::OBSOLETE);
            CPPUNIT_ASSERT(i->getReason() == TransactionItemReason::USER);
            CPPUNIT_ASSERT(i->getRepoid() == "base");
        } else if (i->getId() == 3) {
            CPPUNIT_ASSERT(i->getAction() == TransactionItemAction::OBSOLETED);
            CPPUNIT_ASSERT(i->getReason() == TransactionItemReason::USER);
            CPPUNIT_ASSERT(i->getRepoid() == "f20");
        }

        // CPPUNIT_ASSERT(i->getItem()->getItemType() == "rpm");
        CPPUNIT_ASSERT(i->getDone() == true);
        // std::cout << "TransactionItem: " << i->getItem()->toStr() << std::endl;
        if (i->getItem()->getItemType() == ItemType::GROUP) {
            auto grp = std::dynamic_pointer_cast< CompsGroupItem >(i->getItem());
            CPPUNIT_ASSERT(grp->getPackages().size() == 1);
            for (auto i : grp->getPackages()) {
                // std::cout << "  CompsGroupPackage: " << i->getName() << std::endl;
            }
        }
        if (i->getItem()->getItemType() == ItemType::ENVIRONMENT) {
            auto env = std::dynamic_pointer_cast< CompsEnvironmentItem >(i->getItem());
            CPPUNIT_ASSERT(env->getGroups().size() == 1);
            for (auto i : env->getGroups()) {
                // std::cout << "  CompsEnvironmentGroup: @" << i->getGroupId() << std::endl;
            }
        }
    }
}