Ejemplo n.º 1
0
void TextureRenderer::SetUp() {
    const char vsrc[] =
        "attribute vec4 vPosition;\n"
        "varying vec2 texCoords;\n"
        "uniform mat4 texMatrix;\n"
        "void main() {\n"
        "  vec2 vTexCoords = 0.5 * (vPosition.xy + vec2(1.0, 1.0));\n"
        "  texCoords = (texMatrix * vec4(vTexCoords, 0.0, 1.0)).xy;\n"
        "  gl_Position = vPosition;\n"
        "}\n";

    const char fsrc[] =
        "#extension GL_OES_EGL_image_external : require\n"
        "precision mediump float;\n"
        "uniform samplerExternalOES texSampler;\n"
        "varying vec2 texCoords;\n"
        "void main() {\n"
        "  gl_FragColor = texture2D(texSampler, texCoords);\n"
        "}\n";

    {
        SCOPED_TRACE("creating shader program");
        ASSERT_NO_FATAL_FAILURE(GLTest::createProgram(vsrc, fsrc, &mPgm));
    }

    mPositionHandle = glGetAttribLocation(mPgm, "vPosition");
    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
    ASSERT_NE(-1, mPositionHandle);
    mTexSamplerHandle = glGetUniformLocation(mPgm, "texSampler");
    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
    ASSERT_NE(-1, mTexSamplerHandle);
    mTexMatrixHandle = glGetUniformLocation(mPgm, "texMatrix");
    ASSERT_EQ(GLenum(GL_NO_ERROR), glGetError());
    ASSERT_NE(-1, mTexMatrixHandle);
}
Ejemplo n.º 2
0
TEST_F(WalletApi, initAndSave) {
  SaveOnInitWalletObserver saveOnInit(alice.get());
  alice->addObserver(&saveOnInit);
  alice->initAndGenerate("pass");
  ASSERT_NO_FATAL_FAILURE(WaitWalletSave(aliceWalletObserver.get()));
  alice->shutdown();
}
Ejemplo n.º 3
0
// Tests an interactive PTY session.
TEST_F(ShellServiceTest, InteractivePtySubprocess) {
    ASSERT_NO_FATAL_FAILURE(StartTestSubprocess(
                                "", SubprocessType::kPty, SubprocessProtocol::kShell));

    // Use variable substitution so echoed input is different from output.
    const char* commands[] = {"TEST_STR=abc123",
                              "echo --${TEST_STR}--",
                              "exit"
                             };

    ShellProtocol* protocol = new ShellProtocol(subprocess_fd_);
    for (std::string command : commands) {
        // Interactive shell requires a newline to complete each command.
        command.push_back('\n');
        memcpy(protocol->data(), command.data(), command.length());
        ASSERT_TRUE(protocol->Write(ShellProtocol::kIdStdin, command.length()));
    }
    delete protocol;

    std::string stdout, stderr;
    EXPECT_EQ(0, ReadShellProtocol(subprocess_fd_, &stdout, &stderr));
    // An unpredictable command prompt makes parsing exact output difficult but
    // it should at least contain echoed input and the expected output.
    for (const char* command : commands) {
        EXPECT_FALSE(stdout.find(command) == std::string::npos);
    }
    EXPECT_FALSE(stdout.find("--abc123--") == std::string::npos);
}
void XITServerTest::StartServer() {
    /* No test takes longer than 60 seconds unless we have some envs set
       that suggest we're actually debugging the server */
    if (!getenv("XORG_GTEST_XSERVER_SIGSTOP") &&
        !getenv("XORG_GTEST_XSERVER_KEEPALIVE") &&
        !getenv("XORG_GTEST_USE_VALGRIND")) {
        alarm(TEST_TIMEOUT);
        signal(SIGALRM, sighandler_alarm);
    }

    server.SetOption("-noreset", "");
    server.SetOption("-logverbose", "12");
    server.Start();

    std::string display;
    const char *dpy = getenv("XORG_GTEST_XSERVER_OVERRIDE_DISPLAY");
    if (dpy)
        display = std::string(dpy);
    else
        display = server.GetDisplayString();

    xorg::testing::Test::SetDisplayString(display);

    ASSERT_NO_FATAL_FAILURE(xorg::testing::Test::SetUp());
}
Ejemplo n.º 5
0
TEST_F(WalletApi, initWithKeys) {
  CryptoNote::WalletAccountKeys accountKeys;

  uint8_t byte = 0;

  std::generate(accountKeys.spendPublicKey.begin(), accountKeys.spendPublicKey.end(),
    [&byte] () { return byte++; } );

  std::generate(accountKeys.spendSecretKey.begin(), accountKeys.spendSecretKey.end(),
    [&byte] () { return byte++; } );

  std::generate(accountKeys.viewPublicKey.begin(), accountKeys.viewPublicKey.end(),
    [&byte] () { return byte++; } );

  std::generate(accountKeys.viewSecretKey.begin(), accountKeys.viewSecretKey.end(),
    [&byte] () { return byte++; } );

  alice->initWithKeys(accountKeys, "pass");
  ASSERT_NO_FATAL_FAILURE(WaitWalletLoad(aliceWalletObserver.get()));

  CryptoNote::WalletAccountKeys keys;
  alice->getAccountKeys(keys);

  EXPECT_TRUE(std::equal(accountKeys.spendPublicKey.begin(), accountKeys.spendPublicKey.end(), keys.spendPublicKey.begin()));
  EXPECT_TRUE(std::equal(accountKeys.spendSecretKey.begin(), accountKeys.spendSecretKey.end(), keys.spendSecretKey.begin()));
  EXPECT_TRUE(std::equal(accountKeys.viewPublicKey.begin(), accountKeys.viewPublicKey.end(), keys.viewPublicKey.begin()));
  EXPECT_TRUE(std::equal(accountKeys.viewSecretKey.begin(), accountKeys.viewSecretKey.end(), keys.viewSecretKey.begin()));

  alice->shutdown();
}
Ejemplo n.º 6
0
 void getCurrentMode(uint32_t &w, uint32_t &h) {
     adf_interface_data data;
     ASSERT_NO_FATAL_FAILURE(getInterfaceData(data));
     w = data.current_mode.hdisplay;
     h = data.current_mode.vdisplay;
     adf_free_interface_data(&data);
 }
Ejemplo n.º 7
0
TEST_F(DlExtRelroSharingTest, RelroFileEmpty) {
  int relro_fd = open(relro_file_, O_CREAT | O_RDWR | O_TRUNC, 0644);
  ASSERT_NOERROR(relro_fd);
  ASSERT_NOERROR(close(relro_fd));

  ASSERT_NO_FATAL_FAILURE(TryUsingRelro(LIBNAME));
}
TEST_F(IGraphicBufferProducerTest, Query_ReturnsError) {
    ASSERT_NO_FATAL_FAILURE(ConnectProducer());

    // One past the end of the last 'query' enum value. Update this if we add more enums.
    const int NATIVE_WINDOW_QUERY_LAST_OFF_BY_ONE = NATIVE_WINDOW_BUFFER_AGE + 1;

    int value;
    // What was out of range
    EXPECT_EQ(BAD_VALUE, mProducer->query(/*what*/-1, &value));
    EXPECT_EQ(BAD_VALUE, mProducer->query(/*what*/0xDEADBEEF, &value));
    EXPECT_EQ(BAD_VALUE, mProducer->query(NATIVE_WINDOW_QUERY_LAST_OFF_BY_ONE, &value));

    // Some enums from window.h are 'invalid'
    EXPECT_EQ(BAD_VALUE, mProducer->query(NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER, &value));
    EXPECT_EQ(BAD_VALUE, mProducer->query(NATIVE_WINDOW_CONCRETE_TYPE, &value));
    EXPECT_EQ(BAD_VALUE, mProducer->query(NATIVE_WINDOW_DEFAULT_WIDTH, &value));
    EXPECT_EQ(BAD_VALUE, mProducer->query(NATIVE_WINDOW_DEFAULT_HEIGHT, &value));
    EXPECT_EQ(BAD_VALUE, mProducer->query(NATIVE_WINDOW_TRANSFORM_HINT, &value));
    // TODO: Consider documented the above enums as unsupported or make a new enum for IGBP

    // Value was NULL
    EXPECT_EQ(BAD_VALUE, mProducer->query(NATIVE_WINDOW_FORMAT, /*value*/NULL));

    ASSERT_OK(mConsumer->consumerDisconnect());

    // BQ was abandoned
    EXPECT_EQ(NO_INIT, mProducer->query(NATIVE_WINDOW_FORMAT, &value));

    // TODO: other things in window.h that are supported by Surface::query
    // but not by BufferQueue::query
}
Ejemplo n.º 9
0
void runWithCipher(const string& cipherName, int blockSize,
                   void (*func)(FSConfigPtr& config)) {
  shared_ptr<CipherV1> cipher = CipherV1::New(cipherName);
  ASSERT_TRUE(cipher.get() != NULL);

  FSConfigPtr cfg = makeConfig(cipher, blockSize);
  ASSERT_NO_FATAL_FAILURE(func(cfg));
}
 void drawTexture(bool asSRGB, GLint x, GLint y, GLsizei width,
         GLsizei height) {
     ASSERT_NO_FATAL_FAILURE(fillTexture(asSRGB));
     glViewport(x, y, width, height);
     ASSERT_EQ(GL_NO_ERROR, glGetError());
     glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
     ASSERT_EQ(GL_NO_ERROR, glGetError());
 }
Ejemplo n.º 11
0
TEST(TraceLifecycleTest, threadAttachDetachStress)
{
	/* OMR VM data structures */
	OMRTestVM testVM;
	OMR_VMThread *vmthread = NULL;
	const int attachDetachHelpersCount = 10;
	omrthread_t attachDetachHelpers[attachDetachHelpersCount];
	ChildThreadData *attachDetachData[attachDetachHelpersCount];
	omrthread_t shutdownHelper = NULL;
	ChildThreadData *shutdownData = NULL;

	OMRPORT_ACCESS_FROM_OMRPORT(rasTestEnv->getPortLibrary());
	char *datDir = getTraceDatDir(rasTestEnv->_argc, (const char **)rasTestEnv->_argv);

	OMRTEST_ASSERT_ERROR_NONE(omrTestVMInit(&testVM, OMRPORTLIB));
	/* use small buffers to exercise buffer wrapping */
	OMRTEST_ASSERT_ERROR_NONE(omr_ras_initTraceEngine(&testVM.omrVM, "buffers=1k:maximal=all", datDir));

	/* Attach the thread to the trace engine */
	OMRTEST_ASSERT_ERROR_NONE(OMR_Thread_Init(&testVM.omrVM, NULL, &vmthread, "registerSubscriberAfterShutdown"));
	UT_OMR_TEST_MODULE_LOADED(testVM.omrVM._trcEngine->utIntf);
	/* module is not unloaded before trace engine shutdown */

	for (int i = 0; i < attachDetachHelpersCount; i++) {
		ASSERT_NO_FATAL_FAILURE(startChildThread(&testVM, &attachDetachHelpers[i], attachDetachHelper, &attachDetachData[i]));
	}
	ASSERT_NO_FATAL_FAILURE(startChildThread(&testVM, &shutdownHelper, shutdownTraceHelper, &shutdownData));

	for (int i = 0; i < attachDetachHelpersCount; i++) {
		ASSERT_EQ(1, omrthread_resume(attachDetachHelpers[i]));
	}
	ASSERT_EQ(1, omrthread_resume(shutdownHelper));

	for (int i = 0; i < attachDetachHelpersCount; i++) {
		OMRTEST_ASSERT_ERROR_NONE(waitForChildThread(&testVM, attachDetachHelpers[i], attachDetachData[i]));
	}
	OMRTEST_ASSERT_ERROR_NONE(waitForChildThread(&testVM, shutdownHelper, shutdownData));

	/* Now clear up the VM we started for this test case. */
	UT_OMR_TEST_MODULE_UNLOADED(testVM.omrVM._trcEngine->utIntf);
	OMRTEST_ASSERT_ERROR_NONE(OMR_Thread_Free(vmthread));
	OMRTEST_ASSERT_ERROR_NONE(omrTestVMFini(&testVM));

	ASSERT_TRUE(NULL == (void *)omr_test_UtModuleInfo.intf);
}
Ejemplo n.º 12
0
// Tests a PTY subprocess with no protocol.
TEST_F(ShellServiceTest, PtyNoProtocolSubprocess) {
    // [ -t 0 ] checks if stdin is connected to a terminal.
    ASSERT_NO_FATAL_FAILURE(StartTestSubprocess(
                                "echo foo; echo bar >&2; [ -t 0 ]; echo $?",
                                SubprocessType::kPty, SubprocessProtocol::kNone));

    // [ -t 0 ] == 0 means we have a terminal (PTY).
    ExpectLinesEqual(ReadRaw(subprocess_fd_), {"foo", "bar", "0"});
}
TEST_F(SelectionCollectionTest, HandlesUnsupportedRegularExpressions)
{
    if (!gmx::Regex::isSupported())
    {
        ASSERT_NO_FATAL_FAILURE(loadTopology("simple.gro"));
        EXPECT_THROW_GMX({
                             sc_.parseFromString("resname \"R[AD]\"");
                             sc_.compile();
                         }, gmx::InvalidInputError);
TEST_F(InputPublisherAndConsumerTest, AppendMotionSample_WhenNoMotionEventPublished_ReturnsError) {
    status_t status;
    ASSERT_NO_FATAL_FAILURE(Initialize());

    PointerCoords pointerCoords[1];
    status = mPublisher->appendMotionSample(0, pointerCoords);
    ASSERT_EQ(INVALID_OPERATION, status)
            << "publisher appendMotionSample should return INVALID_OPERATION";
}
Ejemplo n.º 15
0
TEST(JoinTest, createDetachedThread)
{
	omrthread_t helperThr = NULL;

	/* We can't pass any local data to the child thread because we don't guarantee that
	 * it won't go out of scope before the child thread uses it.
	 */
	ASSERT_NO_FATAL_FAILURE(createThread(&helperThr, FALSE, J9THREAD_CREATE_DETACHED, doNothingHelper, NULL));
}
Ejemplo n.º 16
0
TEST( CFPP_WriteStream, Close )
{
    CF::WriteStream s1;
    CF::WriteStream s2( "/etc/hosts" );
    CF::WriteStream s3( "/tmp/com.xs-labs.cfpp" );
    
    s1.Open();
    s2.Open();
    s3.Open();
    
    ASSERT_NO_FATAL_FAILURE( s1.Close() );
    ASSERT_NO_FATAL_FAILURE( s2.Close() );
    ASSERT_NO_FATAL_FAILURE( s3.Close() );
    
    ASSERT_NO_THROW( s1.Close() );
    ASSERT_NO_THROW( s2.Close() );
    ASSERT_NO_THROW( s3.Close() );
}
Ejemplo n.º 17
0
TEST_F(WalletApi, wrongPassword) {
  alice->initAndGenerate("pass");

  ASSERT_NO_FATAL_FAILURE(WaitWalletSync(aliceWalletObserver.get()));

  std::stringstream archive;
  alice->save(archive, true, false);
  ASSERT_NO_FATAL_FAILURE(WaitWalletSave(aliceWalletObserver.get()));

  alice->shutdown();

  prepareAliceWallet();
  alice->initAndLoad(archive, "wrongpass");

  std::error_code result;
  ASSERT_NO_FATAL_FAILURE(WaitWalletLoad(aliceWalletObserver.get(), result));
  EXPECT_EQ(result.value(), cryptonote::error::WRONG_PASSWORD);
}
Ejemplo n.º 18
0
TEST_F(WalletApi, saveAndLoad) {
  alice->initAndGenerate("pass");

  std::error_code result;
  ASSERT_NO_FATAL_FAILURE(WaitWalletLoad(aliceWalletObserver.get(), result));
  ASSERT_EQ(result.value(), 0);

  std::stringstream archive;
  ASSERT_NO_FATAL_FAILURE(alice->save(archive));

  ASSERT_NO_FATAL_FAILURE(WaitWalletSave(aliceWalletObserver.get()));

  prepareAliceWallet();
  alice->initAndLoad(archive, "pass");

  ASSERT_NO_FATAL_FAILURE(WaitWalletLoad(aliceWalletObserver.get(), result));
  ASSERT_EQ(result.value(), 0);
}
Ejemplo n.º 19
0
TEST_F(DlExtRelroSharingTest, VerifyMemorySaving) {
  ASSERT_NO_FATAL_FAILURE(CreateRelroFile(LIBNAME));
  int relro_fd = open(relro_file_, O_RDONLY);
  ASSERT_NOERROR(relro_fd);
  extinfo_.flags |= ANDROID_DLEXT_USE_RELRO;
  extinfo_.relro_fd = relro_fd;
  int pipefd[2];
  ASSERT_NOERROR(pipe(pipefd));

  size_t without_sharing, with_sharing;
  ASSERT_NO_FATAL_FAILURE(SpawnChildrenAndMeasurePss(LIBNAME, false, &without_sharing));
  ASSERT_NO_FATAL_FAILURE(SpawnChildrenAndMeasurePss(LIBNAME, true, &with_sharing));

  // We expect the sharing to save at least 10% of the total PSS. In practice
  // it saves 40%+ for this test.
  size_t expected_size = without_sharing - (without_sharing/10);
  EXPECT_LT(with_sharing, expected_size);
}
Ejemplo n.º 20
0
TEST_F(MotionEventTest, CopyFrom_KeepHistory) {
    MotionEvent event;
    initializeEventWithHistory(&event);

    MotionEvent copy;
    copy.copyFrom(&event, true /*keepHistory*/);

    ASSERT_NO_FATAL_FAILURE(assertEqualsEventWithHistory(&event));
}
Ejemplo n.º 21
0
TEST( CFPP_WriteStream, WriteAll_BytePtr_CFIndex )
{
    CF::WriteStream s1;
    CF::WriteStream s2( "/etc/hosts" );
    CF::WriteStream s3( "/tmp/com.xs-labs.cfpp" );
    CF::Data::Byte  buf[ 4 ];
    
    buf[ 0 ] = 0xDE;
    buf[ 1 ] = 0xAD;
    buf[ 2 ] = 0xBE;
    buf[ 3 ] = 0xEF;
    
    ASSERT_FALSE( s1.WriteAll( buf, sizeof( buf ) ) );
    ASSERT_FALSE( s2.WriteAll( buf, sizeof( buf ) ) );
    ASSERT_FALSE( s3.WriteAll( buf, sizeof( buf ) ) );
    
    s1.Open();
    s2.Open();
    s3.Open();
    
    ASSERT_FALSE( s1.WriteAll( buf, sizeof( buf ) ) );
    ASSERT_FALSE( s2.WriteAll( buf, sizeof( buf ) ) );
    ASSERT_TRUE(  s3.WriteAll( buf, sizeof( buf ) ) );
    
    ASSERT_NO_FATAL_FAILURE( s1.WriteAll( NULL, sizeof( buf ) ) );
    ASSERT_NO_FATAL_FAILURE( s2.WriteAll( NULL, sizeof( buf ) ) );
    ASSERT_NO_FATAL_FAILURE( s3.WriteAll( NULL, sizeof( buf ) ) );
    
    ASSERT_NO_THROW( s1.WriteAll( NULL, sizeof( buf ) ) );
    ASSERT_NO_THROW( s2.WriteAll( NULL, sizeof( buf ) ) );
    ASSERT_NO_THROW( s3.WriteAll( NULL, sizeof( buf ) ) );
    
    ASSERT_FALSE( s1.WriteAll( NULL, sizeof( buf ) ) );
    ASSERT_FALSE( s2.WriteAll( NULL, sizeof( buf ) ) );
    ASSERT_FALSE( s3.WriteAll( NULL, sizeof( buf ) ) );
    
    s1.Close();
    s2.Close();
    s3.Close();
    
    ASSERT_FALSE( s1.WriteAll( buf, sizeof( buf ) ) );
    ASSERT_FALSE( s2.WriteAll( buf, sizeof( buf ) ) );
    ASSERT_FALSE( s3.WriteAll( buf, sizeof( buf ) ) );
}
TEST_F(IGraphicBufferProducerTest, Disconnect_ReturnsError) {
    ASSERT_NO_FATAL_FAILURE(ConnectProducer());

    // Must disconnect with same API number
    ASSERT_EQ(BAD_VALUE, mProducer->disconnect(TEST_API_OTHER));
    // API must not be out of range
    ASSERT_EQ(BAD_VALUE, mProducer->disconnect(/*api*/0xDEADBEEF));

    // TODO: somehow kill mProducer so that this returns DEAD_OBJECT
}
Ejemplo n.º 23
0
TEST_F(AdfTest, attach) {
    ASSERT_NO_FATAL_FAILURE(attach());
    int err = adf_device_attach(&dev, eng_id, intf_id);
    EXPECT_EQ(-EALREADY, err) << "attaching overlay engine " << eng_id <<
            " to interface " << intf_id << " twice should have failed";

    ASSERT_NO_FATAL_FAILURE(detach());
    err = adf_device_detach(&dev, eng_id, intf_id);
    EXPECT_EQ(-EINVAL, err) << "detaching overlay engine " << eng_id <<
            " from interface " << intf_id << " twice should have failed";

    err = adf_device_attach(&dev, eng_id, ADF_MAX_INTERFACES);
    EXPECT_EQ(-EINVAL, err) << "attaching overlay engine " << eng_id <<
            " to bogus interface should have failed";

    err = adf_device_detach(&dev, eng_id, ADF_MAX_INTERFACES);
    EXPECT_EQ(-EINVAL, err) << "detaching overlay engine " << eng_id <<
            " from bogus interface should have failed";
}
Ejemplo n.º 24
0
TEST_F(WalletApi, sendAfterFailedTransaction) {
  alice->initAndGenerate("pass");
  ASSERT_NO_FATAL_FAILURE(WaitWalletSync(aliceWalletObserver.get()));

  GetOneBlockReward(*alice);
  generator.generateEmptyBlocks(10);
  aliceNode->updateObservers();
  ASSERT_NO_FATAL_FAILURE(WaitWalletSync(aliceWalletObserver.get()));

  CryptoNote::Transfer tr;
  tr.amount = 100000;
  tr.address = "wrong_address";

  EXPECT_THROW(alice->sendTransaction(tr, 1000, "", 2, 0), std::system_error);
  CryptoNote::TransactionId txId = TransferMoney(*alice, *alice, 100000, 100);
  ASSERT_NE(txId, CryptoNote::INVALID_TRANSACTION_ID);
  ASSERT_NO_FATAL_FAILURE(WaitWalletSend(aliceWalletObserver.get()));
  alice->shutdown();
}
Ejemplo n.º 25
0
// Tests a raw subprocess with the shell protocol.
TEST_F(ShellServiceTest, RawShellProtocolSubprocess) {
    ASSERT_NO_FATAL_FAILURE(StartTestSubprocess(
                                "echo foo; echo bar >&2; echo baz; exit 24",
                                SubprocessType::kRaw, SubprocessProtocol::kShell));

    std::string stdout, stderr;
    EXPECT_EQ(24, ReadShellProtocol(subprocess_fd_, &stdout, &stderr));
    ExpectLinesEqual(stdout, {"foo", "baz"});
    ExpectLinesEqual(stderr, {"bar"});
}
Ejemplo n.º 26
0
// Tests that nothing breaks when the stderr pipe closes.
TEST_F(ShellServiceTest, CloseStderrSubprocess) {
    ASSERT_NO_FATAL_FAILURE(StartTestSubprocess(
                                "exec 2>&-; echo foo",
                                SubprocessType::kRaw, SubprocessProtocol::kShell));

    std::string stdout, stderr;
    EXPECT_EQ(0, ReadShellProtocol(subprocess_fd_, &stdout, &stderr));
    ExpectLinesEqual(stdout, {"foo"});
    ExpectLinesEqual(stderr, {});
}
Ejemplo n.º 27
0
TEST_F(WalletApi, saveAndLoadErroneousTxsCacheNoDetails) {
  prepareBobWallet();
  prepareCarolWallet();

  alice->initAndGenerate("pass");

  ASSERT_NO_FATAL_FAILURE(WaitWalletSync(aliceWalletObserver.get()));

  ASSERT_NO_FATAL_FAILURE(GetOneBlockReward(*alice));
  generator.generateEmptyBlocks(10);
  alice->startRefresh();
  ASSERT_NO_FATAL_FAILURE(WaitWalletSync(aliceWalletObserver.get()));

  bob->initAndGenerate("pass");
  ASSERT_NO_FATAL_FAILURE(WaitWalletSync(bobWalletObserver.get()));

  carol->initAndGenerate("pass");
  ASSERT_NO_FATAL_FAILURE(WaitWalletSync(carolWalletObserver.get()));

  std::array<int64_t, 5> amounts;
  amounts[0] = 1234567;
  amounts[1] = 1345678;
  amounts[2] = 1456789;
  amounts[3] = 1567890;
  amounts[4] = 1678901;
  uint64_t fee = 10000;

  ASSERT_NO_FATAL_FAILURE(performTransferWithErrorTx(amounts, fee));

  std::stringstream archive;
  alice->save(archive, false, true);

  ASSERT_NO_FATAL_FAILURE(WaitWalletSave(aliceWalletObserver.get()));

  prepareAliceWallet();
  alice->initAndLoad(archive, "pass");

  std::error_code result;
  ASSERT_NO_FATAL_FAILURE(WaitWalletLoad(aliceWalletObserver.get(), result));
  ASSERT_EQ(result.value(), 0);

  EXPECT_EQ(alice->getTransactionCount(), 2);
  EXPECT_EQ(alice->getTransferCount(), 0);

  CryptoNote::Transaction tx;
  ASSERT_TRUE(alice->getTransaction(1, tx));
  EXPECT_EQ(tx.totalAmount, amounts[3] + amounts[4] + fee);
  EXPECT_EQ(tx.firstTransferId, CryptoNote::INVALID_TRANSFER_ID);
  EXPECT_EQ(tx.transferCount, 0);

  alice->shutdown();
}
Ejemplo n.º 28
0
TEST_F(WalletApi, checkPendingBalance) {
  alice->initAndGenerate("pass");
  ASSERT_NO_FATAL_FAILURE(WaitWalletSync(aliceWalletObserver.get()));

  prepareBobWallet();
  bob->initAndGenerate("pass");
  ASSERT_NO_FATAL_FAILURE(WaitWalletSync(bobWalletObserver.get()));

  GetOneBlockReward(*alice);
  generator.generateEmptyBlocks(10);

  aliceNode->updateObservers();
  ASSERT_NO_FATAL_FAILURE(WaitWalletSync(aliceWalletObserver.get()));

  uint64_t startActualBalance = alice->actualBalance();
  int64_t sendAmount = 304050;
  uint64_t fee = m_currency.minimumFee();

  CryptoNote::Transfer tr;
  tr.address = bob->getAddress();
  tr.amount = sendAmount;

  auto txId = alice->sendTransaction(tr, fee, "", 1, 0);
  ASSERT_NE(txId, CryptoNote::INVALID_TRANSACTION_ID);

  std::error_code sendResult;
  ASSERT_NO_FATAL_FAILURE(WaitWalletSend(aliceWalletObserver.get(), sendResult));
  ASSERT_EQ(std::error_code(), sendResult);

  uint64_t totalBalance = alice->actualBalance() + alice->pendingBalance();
  ASSERT_EQ(startActualBalance - sendAmount - fee, totalBalance);

  generator.generateEmptyBlocks(1);
  bobNode->updateObservers();
  ASSERT_NO_FATAL_FAILURE(WaitWalletSync(bobWalletObserver.get()));

  ASSERT_EQ(sendAmount, bob->actualBalance());
  ASSERT_EQ(0, bob->pendingBalance());

  alice->shutdown();
  bob->shutdown();
}
Ejemplo n.º 29
0
TEST_F(AdfTest, interface_data) {
    adf_interface_data data;
    ASSERT_NO_FATAL_FAILURE(getInterfaceData(data));

    EXPECT_LT(data.type, ADF_INTF_TYPE_MAX);
    EXPECT_LE(data.dpms_state, DRM_MODE_DPMS_OFF);
    EXPECT_EQ(1, data.hotplug_detect);
    EXPECT_GT(data.n_available_modes, 0);
    EXPECT_LT(data.custom_data_size, ADF_MAX_CUSTOM_DATA_SIZE);
    adf_free_interface_data(&data);
}
Ejemplo n.º 30
0
TEST_F(AdfTest, blank) {
    int err = adf_interface_blank(intf, (uint8_t)-1);
    EXPECT_EQ(-EINVAL, err) << "setting bogus DPMS mode should have failed";

    err = adf_interface_blank(eng, DRM_MODE_DPMS_OFF);
    EXPECT_EQ(-EINVAL, err) << "blanking overlay engine should have failed";

    ASSERT_NO_FATAL_FAILURE(blank(DRM_MODE_DPMS_OFF));
    err = adf_interface_blank(intf, DRM_MODE_DPMS_OFF);
    EXPECT_EQ(-EBUSY, err) << "blanking interface twice should have failed";

    ASSERT_NO_FATAL_FAILURE(blank(DRM_MODE_DPMS_ON));
    err = adf_interface_blank(intf, DRM_MODE_DPMS_ON);
    EXPECT_EQ(-EBUSY, err) << "unblanking interface twice should have failed";

    adf_interface_data data;
    ASSERT_NO_FATAL_FAILURE(getInterfaceData(data));
    EXPECT_EQ(DRM_MODE_DPMS_ON, data.dpms_state);
    adf_free_interface_data(&data);
}