void VerifySticker::runTest() { QProcess avrdude; emit testMessage(testName(), infoMessage, stickerNum, QString("Verifying sticker ") + QString::number(stickerNum)); selectSticker(stickerNum); avrdude.start("./avrdude", QStringList() << "-C" << configFile << "-c" << "linuxgpio" << "-P" << "linuxgpio" << "-p" << partName << "-U" << (QString("flash:v:") + firmwareFile) ); if (!avrdude.waitForStarted()) { testError("Unable to start avrdude"); return; } avrdude.closeWriteChannel(); if (!avrdude.waitForFinished()) { testError("avrdude never finished"); return; } if (avrdude.exitCode()) { testError(QString("Failed to verify")); return; } emit testMessage(testName(), testPass, stickerNum, "Test passed"); }
static void testGetType( PKIX_PL_Object *obj, PKIX_PL_Object *obj2, PKIX_PL_Object *obj3) { PKIX_UInt32 testType; PKIX_TEST_STD_VARS(); PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Object_GetType(obj, &testType, plContext)); if (testType != 1000) testError("Object 1 returned the wrong type"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Object_GetType(obj2, &testType, plContext)); if (testType != 2000) testError("Object 2 returned the wrong type"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Object_GetType(obj3, &testType, plContext)); if (testType != 1000) testError("Object 3 returned the wrong type"); cleanup: PKIX_TEST_RETURN(); }
static void testCompare( PKIX_PL_Object *obj2, PKIX_PL_Object *obj4) { PKIX_Int32 cmpResult; PKIX_TEST_STD_VARS(); *(char *)obj2 = 0x20; *(char *)obj4 = 0x10; PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Object_Compare(obj2, obj4, &cmpResult, plContext)); if (cmpResult <= 0) testError("Invalid Result from Object Compare"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Object_Compare(obj4, obj2, &cmpResult, plContext)); if (cmpResult >= 0) testError("Invalid Result from Object Compare"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Object_Compare(obj4, obj4, &cmpResult, plContext)); *(char *)obj2 = 0x10; if (cmpResult != 0) testError("Invalid Result from Object Compare"); cleanup: PKIX_TEST_RETURN(); }
int ProgramSenoko::prepGPIO(void) { QFile exportFile("/sys/class/gpio/export"); if (!exportFile.open(QIODevice::WriteOnly)) { testError(QString() + "Unable to open GPIO export file: " + exportFile.errorString()); return 1; } exportFile.write("149"); exportFile.close(); QFile directionFile("/sys/class/gpio/gpio149/direction"); if (!directionFile.open(QIODevice::WriteOnly)) { testError(QString() + "Unable to open GPIO149 direction file: " + directionFile.errorString()); return 1; } directionFile.write("out\n"); directionFile.close(); QFile valueFile("/sys/class/gpio/gpio149/value"); if (!valueFile.open(QIODevice::WriteOnly)) { testError(QString() + "Unable to open GPIO149 value file: " + valueFile.errorString()); return 1; } valueFile.write("0\n"); valueFile.close(); return 0; }
static void testMaxLoggingLevel(PKIX_Logger *logger) { PKIX_UInt32 level = 0; PKIX_TEST_STD_VARS(); subTest("PKIX_Logger_GetMaxLoggingLevel"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_GetMaxLoggingLevel (logger, &level, plContext)); if (level != 0) { testError("Incorrect Logger MaxLoggingLevel returned"); } subTest("PKIX_Logger_SetMaxLoggingLevel"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_SetMaxLoggingLevel (logger, 3, plContext)); subTest("PKIX_Logger_GetMaxLoggingLevel"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_GetMaxLoggingLevel (logger, &level, plContext)); if (level != 3) { testError("Incorrect Logger MaxLoggingLevel returned"); } cleanup: PKIX_TEST_RETURN(); }
void read_map_t(char *name, peak_param *peak, map_t *kMap, mapType_t type, error **err) { testError(kMap->length!=peak->resol[0]*peak->resol[1], peak_match, "Resolution match error", *err, __LINE__); forwardError(*err, __LINE__,); FILE *file = fopen_err(name, "r", err); forwardError(*err, __LINE__,); char buffer[STRING_LENGTH_MAX], *buffer1; int buffer2, count = 0; double *kappa = kMap->kappa; //-- Read int c = fgetc(file); while (c != EOF) { if (c == (int)'#') buffer1 = fgets(buffer, STRING_LENGTH_MAX, file); else { testError(count>=kMap->length, peak_overflow, "Too many pixels", *err, __LINE__); forwardError(*err, __LINE__,); ungetc(c, file); buffer2 = fscanf(file, "%*f %*f %lf\n", &kappa[count]); count++; } c = fgetc(file); } fclose(file); //-- Length check testError(count!=kMap->length, peak_match, "Array length error", *err, __LINE__); forwardError(*err, __LINE__,); kMap->type = type; printf("\"%s\" read\n", name); return; }
static void testComponent(PKIX_Logger *logger) { PKIX_ERRORCLASS compName = (PKIX_ERRORCLASS)NULL; PKIX_ERRORCLASS compNameReturn = (PKIX_ERRORCLASS)NULL; PKIX_Boolean cmpResult = PKIX_FALSE; PKIX_TEST_STD_VARS(); subTest("PKIX_Logger_GetLoggingComponent"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_GetLoggingComponent (logger, &compName, plContext)); if (compName != (PKIX_ERRORCLASS)NULL) { testError("Incorrect Logger Component returned. expect <NULL>"); } subTest("PKIX_Logger_SetLoggingComponent"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_SetLoggingComponent (logger, PKIX_LIST_ERROR, plContext)); subTest("PKIX_Logger_GetLoggingComponent"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_GetLoggingComponent (logger, &compNameReturn, plContext)); if (compNameReturn != PKIX_LIST_ERROR) { testError("Incorrect Logger Component returned."); } cleanup: PKIX_TEST_RETURN(); }
void SetStickerFuse::runTest() { QProcess avrdude; emit testMessage(testName(), infoMessage, stickerNum, QString("Setting fuse ") + fuseName + " to 0x" + QString::number(fuseValue, 16)); selectSticker(stickerNum); avrdude.start("./avrdude", QStringList() << "-C" << configFile << "-c" << "linuxgpio" << "-P" << "linuxgpio" << "-p" << partName << "-U" << (QString() + fuseName + ":w:0x" + QString::number(fuseValue, 16) + ":m") ); if (!avrdude.waitForStarted()) { testError("Unable to start avrdude"); return; } avrdude.closeWriteChannel(); if (!avrdude.waitForFinished()) { testError("avrdude never finished"); return; } if (avrdude.exitCode()) { testError(QString("avrdude returned an error: ") + avrdude.readAll()); return; } }
/* * Compare two CSSM_DATEs. Returns nonzero on error. */ static int compareDates( const CSSM_DATE *refDate, // what we tried to set, or NULL const CSSM_DATE *keyDate, const char *op, CSSM_BOOL quiet) { if(refDate == NULL) { /* make sure key date is empty */ bool isZero = true; unsigned char *cp = (unsigned char *)keyDate; for(unsigned i=0; i<sizeof(CSSM_DATE); i++) { if(*cp++ != 0) { isZero = false; break; } } if(!isZero) { printf("%s: refDate NULL, non-empty keyDate\n", op); return testError(quiet); } else { return 0; } } if(memcmp(refDate, keyDate, sizeof(CSSM_DATE))) { printf("%s: refDate/keyDate MISCOMPARE\n", op); return testError(quiet); } else { return 0; } }
static void test_KeyUsages(void) { PKIX_ComCertSelParams *goodParams = NULL; PKIX_PL_OID *ekuOid = NULL; PKIX_List *setExtKeyUsage = NULL; PKIX_List *getExtKeyUsage = NULL; PKIX_UInt32 getKeyUsage = 0; PKIX_UInt32 setKeyUsage = 0x1FF; PKIX_Boolean isEqual = PKIX_FALSE; PKIX_TEST_STD_VARS(); subTest("PKIX_ComCertSelParams_Create"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_ComCertSelParams_Create(&goodParams, plContext)); subTest("PKIX_ComCertSelParams_SetKeyUsage"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_ComCertSelParams_SetKeyUsage(goodParams, setKeyUsage, plContext)); subTest("PKIX_ComCertSelParams_GetKeyUsage"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_ComCertSelParams_GetKeyUsage(goodParams, &getKeyUsage, plContext)); if (setKeyUsage != getKeyUsage) { testError("unexpected KeyUsage mismatch <expect equal>"); } subTest("PKIX_PL_OID List create and append"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_Create(&setExtKeyUsage, plContext)); PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_OID_Create("1.3.6.1.5.5.7.3.1", &ekuOid, plContext)); PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_AppendItem(setExtKeyUsage, (PKIX_PL_Object *)ekuOid, plContext)); PKIX_TEST_DECREF_BC(ekuOid); PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_OID_Create("1.3.6.1.5.5.7.3.8", &ekuOid, plContext)); PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_AppendItem(setExtKeyUsage, (PKIX_PL_Object *)ekuOid, plContext)); PKIX_TEST_DECREF_BC(ekuOid); subTest("PKIX_ComCertSelParams_SetExtendedKeyUsage"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_ComCertSelParams_SetExtendedKeyUsage(goodParams, setExtKeyUsage, plContext)); subTest("PKIX_ComCertSelParams_GetExtendedKeyUsage"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_ComCertSelParams_GetExtendedKeyUsage(goodParams, &getExtKeyUsage, plContext)); PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Object_Equals((PKIX_PL_Object *)setExtKeyUsage, (PKIX_PL_Object *)getExtKeyUsage, &isEqual, plContext)); if (isEqual == PKIX_FALSE) { testError("unexpected ExtKeyUsage mismatch <expect equal>"); } cleanup: PKIX_TEST_DECREF_AC(ekuOid); PKIX_TEST_DECREF_AC(setExtKeyUsage); PKIX_TEST_DECREF_AC(getExtKeyUsage); PKIX_TEST_DECREF_AC(goodParams); PKIX_TEST_RETURN(); }
//TODO: make it robust Playback::Playback(const string &file_name, float volume) :m_file_name(file_name) { DASSERT(isInitialized()); memset(m_buffer_ids, 0, sizeof(m_buffer_ids)); m_source_id = 0; try { alGetError(); alGenBuffers(max_buffers, (ALuint*)m_buffer_ids); testError("Error while creating buffers for music playback."); alGenSources(1, (ALuint*)&m_source_id); testError("Error while creating source for music playback."); m_decoder.reset(new MP3Decoder(m_file_name)); for(int n = 0; n < max_buffers; n++) feedMoreData(m_buffer_ids[n]); alSource3f(m_source_id, AL_POSITION, 0.0f, 0.0f, 0.0f); alSource3f(m_source_id, AL_VELOCITY, 0.0f, 0.0f, 0.0f); alSource3f(m_source_id, AL_DIRECTION, 0.0f, 0.0f, 0.0f); alSourcef (m_source_id, AL_ROLLOFF_FACTOR, 0.0f); alSourcei (m_source_id, AL_SOURCE_RELATIVE, AL_TRUE); alSourcePlay(m_source_id); m_mode = mode_playing; } catch(...) { free(); throw; } }
void addNoise(map_t *kMap, map_t *nMap, error **err) { testError(kMap->N1!=nMap->N1, peak_match, "Map size error", *err, __LINE__); forwardError(*err, __LINE__,); testError(kMap->N2!=nMap->N2, peak_match, "Map size error", *err, __LINE__); forwardError(*err, __LINE__,); testError(!((kMap->type==kappa_map && nMap->type==noise_map) || (kMap->type==K_map && nMap->type==N_map)), peak_mapType, "Map type error", *err, __LINE__); forwardError(*err, __LINE__,); int i; for (i=0; i<kMap->length; i++) kMap->kappa[i] += nMap->kappa[i]; if (kMap->type==kappa_map) kMap->type = kn_map; else kMap->type = KN_map; return; }
/* * Common, flexible, error-tolerant symmetric key generator. */ static int genSymKey( CSSM_CSP_HANDLE cspHand, CSSM_KEY_PTR symKey, uint32 alg, const char *keyAlgStr, uint32 keySizeInBits, CSSM_KEYATTR_FLAGS keyAttr, CSSM_KEYUSE keyUsage, CSSM_RETURN expectRtn, CSSM_BOOL quiet, CSSM_BOOL freeKey, // true: free the key on exit const char *testStr) { CSSM_RETURN crtn; CSSM_CC_HANDLE ccHand; CSSM_DATA dummyLabel = {4, (uint8 *)"foo"}; int irtn; memset(symKey, 0, sizeof(CSSM_KEY)); crtn = CSSM_CSP_CreateKeyGenContext(cspHand, alg, keySizeInBits, // keySizeInBits NULL, // Seed NULL, // Salt NULL, // StartDate NULL, // EndDate NULL, // Params &ccHand); if(crtn) { printError("CSSM_CSP_CreateKeyGenContext", crtn); return testError(quiet); } crtn = CSSM_GenerateKey(ccHand, keyUsage, keyAttr, &dummyLabel, NULL, // ACL symKey); if(crtn != expectRtn) { printf("***Testing %s for alg %s:\n", testStr, keyAlgStr); printf(" CSSM_GenerateKey: expect %s\n", cssmErrToStr(expectRtn)); printf(" CSSM_GenerateKey: got %s\n", cssmErrToStr(crtn)); irtn = testError(quiet); } else { irtn = 0; } CSSM_DeleteContext(ccHand); if(freeKey && (crtn == CSSM_OK)) { cspFreeKey(cspHand, symKey); } return irtn; }
static int doVerify( CSSM_CSP_HANDLE cspHand, const char *algStr, CSSM_KEY_PTR key, // private CSSM_ALGORITHMS sigAlg, CSSM_RETURN expRtn, // expected result CSSM_BOOL quiet) { uint8 ptextData[PTEXT_SIZE]; CSSM_DATA ptext = {PTEXT_SIZE, ptextData}; uint8 sigData[PTEXT_SIZE]; CSSM_DATA sig = {PTEXT_SIZE, sigData}; simpleGenData(&ptext, PTEXT_SIZE, PTEXT_SIZE); memset(sigData, 0, PTEXT_SIZE); CSSM_CC_HANDLE cryptHand = 0; CSSM_RETURN crtn; crtn = CSSM_CSP_CreateSignatureContext(cspHand, sigAlg, NULL, // passPhrase key, &cryptHand); if(crtn) { printError("CSSM_CSP_CreateSignatureContext (2)", crtn); return testError(quiet); } int irtn = 0; crtn = CSSM_VerifyData(cryptHand, &ptext, 1, CSSM_ALGID_NONE, &sig); if(crtn != expRtn) { if(expRtn == CSSM_OK) { printError("CSSM_VerifyData", crtn); printf("Unexpected error verifying with %s\n", algStr); } else { printf("***Verify with %s: expected %s, got %s.\n", algStr, cssmErrToStr(expRtn), cssmErrToStr(crtn)); } irtn = testError(quiet); } CSSM_DeleteContext(cryptHand); return irtn; }
static void testContextCallback(PKIX_Logger *logger, PKIX_Logger *logger2) { PKIX_Logger_LogCallback cb = NULL; PKIX_PL_Object *context = NULL; PKIX_Boolean cmpResult = PKIX_FALSE; PKIX_UInt32 length; PKIX_TEST_STD_VARS(); subTest("PKIX_Logger_GetLoggerContext"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_GetLoggerContext (logger2, &context, plContext)); testEqualsHelper ((PKIX_PL_Object *)logger, context, PKIX_TRUE, plContext); subTest("PKIX_Logger_GetLogCallback"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_Logger_GetLogCallback (logger, &cb, plContext)); if (cb != testLoggerCallback) { testError("Incorrect Logger Callback returned"); } cleanup: PKIX_TEST_DECREF_AC(context); PKIX_TEST_RETURN(); }
static void testRealloc(PKIX_UInt32 **array) { PKIX_UInt32 i, arraySize = 20; PKIX_TEST_STD_VARS(); PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Realloc(*array, (PKIX_UInt32)(arraySize*sizeof (unsigned int)), (void **) array, plContext)); /* Fill in the new elements */ (void) printf ("Setting new portion of array to a[i] = i...\n"); for (i = arraySize/2; i < arraySize; i++) { (*array)[i] = i; if ((*array)[i] != i) testError("Array has incorrect contents"); } /* New elements should be reflected. The old should be the same */ (void) printf("\tArray: a[0] = %d, a[15] = %d, a[17] = %d.\n", (*array)[0], (*array)[15], (*array)[17]); cleanup: PKIX_TEST_RETURN(); }
static PKIX_Error *testLoggerCallback( PKIX_Logger *logger, PKIX_PL_String *message, PKIX_UInt32 logLevel, PKIX_ERRORCLASS logComponent, void *plContext) { char *comp = NULL; char *msg = NULL; char result[100]; static int callCount = 0; PKIX_TEST_STD_VARS(); msg = PKIX_String2ASCII(message, plContext); PR_snprintf(result, 100, "Logging %s (%s): %s", levels[logLevel], PKIX_ERRORCLASSNAMES[logComponent], msg); subTest(result); callCount++; if (callCount > 1) { testError("Incorrect number of Logger Callback <expect 1>"); } cleanup: PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Free(msg, plContext)); PKIX_TEST_RETURN(); }
static void test_GetDepth( PKIX_PolicyNode *depth1Node, PKIX_PolicyNode *depth2Node, PKIX_PolicyNode *depth3Node) { PKIX_UInt32 depth1 = 0; PKIX_UInt32 depth2 = 0; PKIX_UInt32 depth3 = 0; PKIX_TEST_STD_VARS(); subTest("PKIX_PolicyNode_GetDepth"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_PolicyNode_GetDepth (depth1Node, &depth1, plContext)); PKIX_TEST_EXPECT_NO_ERROR(PKIX_PolicyNode_GetDepth (depth2Node, &depth2, plContext)); PKIX_TEST_EXPECT_NO_ERROR(PKIX_PolicyNode_GetDepth (depth3Node, &depth3, plContext)); if ((depth1 != 1) || (depth2 != 2) || (depth3 != 3)) { testError("GetDepth returned unexpected value"); } cleanup: PKIX_TEST_RETURN(); }
static void test_IsCritical( PKIX_PolicyNode *goodNode, PKIX_PolicyNode *equalNode, PKIX_PolicyNode *diffNode) { PKIX_Boolean goodBool = PKIX_FALSE; PKIX_Boolean equalBool = PKIX_FALSE; PKIX_Boolean diffBool = PKIX_FALSE; PKIX_TEST_STD_VARS(); subTest("PKIX_PolicyNode_IsCritical"); PKIX_TEST_EXPECT_NO_ERROR(PKIX_PolicyNode_IsCritical (goodNode, &goodBool, plContext)); PKIX_TEST_EXPECT_NO_ERROR(PKIX_PolicyNode_IsCritical (equalNode, &equalBool, plContext)); PKIX_TEST_EXPECT_NO_ERROR(PKIX_PolicyNode_IsCritical (diffNode, &diffBool, plContext)); if ((!goodBool) || (!equalBool) || (diffBool)) { testError("IsCritical returned unexpected value"); } cleanup: PKIX_TEST_RETURN(); }
void doFFTSmoothing(peak_param *peak, map_t *kMap, FFT_t *transformer, error **err) { testError((kMap->type!=kappa_map && kMap->type!=noise_map && kMap->type!=kn_map), peak_mapType, "Map type error", *err, __LINE__); forwardError(*err, __LINE__,); reset_FFT_t(transformer); int M1 = transformer->N1; int N1 = kMap->N1; int N2 = kMap->N2; //-- Fill transformer->before and add zero-padding int i, j; for (i=0; i<N1; i++) { for (j=0; j<N2; j++) { transformer->before[i+j*M1] = kMap->kappa[i+j*N1]; } } execute_FFT_t(transformer); //-- Retrieve values from transformer->after, set to smoothed->kappa for (i=0; i<N1; i++) { for (j=0; j<N2; j++) { kMap->kappa[i+j*N1] = transformer->after[i+j*M1]; } } if (kMap->type == kappa_map) kMap->type = K_map; else if (kMap->type == noise_map) kMap->type = N_map; else kMap->type = KN_map; if (peak->printMode != 1) printf("Smoothing with FFT done\n"); return; }
static void testMalloc(PKIX_UInt32 **array) { PKIX_UInt32 i, arraySize = 10; PKIX_TEST_STD_VARS(); /* Create an integer array of size 10 */ PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Malloc( (PKIX_UInt32)(arraySize*sizeof (unsigned int)), (void **) array, plContext)); /* Fill in some values */ (void) printf ("Setting array[i] = i...\n"); for (i = 0; i < arraySize; i++) { (*array)[i] = i; if ((*array)[i] != i) testError("Array has incorrect contents"); } /* Memory now reflects changes */ (void) printf("\tArray: a[0] = %d, a[5] = %d, a[7] = %d.\n", (*array[0]), (*array)[5], (*array)[7]); cleanup: PKIX_TEST_RETURN(); }
/** * @brief Configure video format emitted by encoder output port. * @author Tuomas Jormola * Copyright © 2013 Tuomas Jormola <*****@*****.**> <http://solitudo.net> */ static void _EncoderHandler_ConfigureOutputFormat(BasicOMXHandler* self) { OMX_HANDLETYPE encoder = self -> type ; (self -> portDef).nPortIndex = PORT_ENCODER_OUTPUT ; testError(OMX_GetParameter(encoder, OMX_IndexParamPortDefinition, &(self -> portDef)), "Failed to get port definition for encoder output port 201") ; }
void read_particle_arr(char name[], particle_arr *part, double *diffArr, error **err) { //-- WARNING: d-dependent FILE *file = fopen_err(name, "r", err); forwardError(*err, __LINE__,); char buffer[STRING_LENGTH_MAX], *buffer1; int buffer2, count = 0; particle_t *pa; double pos[2], w, z, M; int c = fgetc(file); while (c != EOF) { if (c == (int)'#') buffer1 = fgets(buffer, STRING_LENGTH_MAX, file); else { testError(count==part->p, peak_overflow, "Too many particles", *err, __LINE__); forwardError(*err, __LINE__,); ungetc(c, file); pa = part->array[count]; buffer2 = fscanf(file, "%lf %lf %lf %lf\n", &pa->param[0], &pa->param[1], &pa->weight, &pa->diff); count++; } c = fgetc(file); } fclose(file); printf("\"%s\" read\n", name); printf("%d particles generated\n", count); updateEpsilon_particle_arr(part, diffArr); updateMean_particle_arr(part); updateCovariance_particle_arr(part); return; }
static void consumer(/* ARGSUSED */ void *arg) { PRStatus status = PR_SUCCESS; PKIX_Error *errorResult; int i = 0; for (i = 0; i < 5; i++) { (void)PKIX_PL_Mutex_Lock(mutex, plContext); while (((box1 == 0) || (box2 == 0) || (box3 == 0)) && (status == PR_SUCCESS)) status = PR_WaitCondVar(cv, PR_INTERVAL_NO_TIMEOUT); (void)printf("\tConsumer got Box1 = %d ", box1); box1 = 0; (void)printf("Box2 = %d ", box2); box2 = 0; (void)printf("Box3 = %d\n", box3); box3 = 0; status = PR_NotifyAllCondVar(cv); if (status == PR_FAILURE) (void)printf("Consumer error while notifying condvar\n"); errorResult = PKIX_PL_Mutex_Unlock(mutex, plContext); if (errorResult) testError("PKIX_PL_Mutex_Unlock failed"); } (void)printf("Consumer exiting...\n"); }
static void producer(void *arg) { PRStatus status = PR_SUCCESS; int value = *(int *)arg; int i = 0; int *box; PKIX_Error *errorResult; if (value == 10) box = &box1; else if (value == 20) box = &box2; else if (value == 30) box = &box3; for (i = 0; i < 5; i++) { (void)PKIX_PL_Mutex_Lock(mutex, plContext); while ((*box != 0) && (status == PR_SUCCESS)) status = PR_WaitCondVar(cv, PR_INTERVAL_NO_TIMEOUT); *box = i + 1; (void)printf("\tProducer %d put value: %d\n", value, *box); status = PR_NotifyAllCondVar(cv); if (status == PR_FAILURE) (void)printf("Producer %d error while notifying condvar\n", value); errorResult = PKIX_PL_Mutex_Unlock(mutex, plContext); if (errorResult) testError("PKIX_PL_Mutex_Unlock failed"); } }
static void testGetSetPolicyQualifiersRejected( PKIX_ProcessingParams *goodObject, PKIX_Boolean rejected) { PKIX_Boolean getRejected = PKIX_FALSE; PKIX_TEST_STD_VARS(); subTest("PKIX_ProcessingParams_Get/SetPolicyQualifiersRejected"); PKIX_TEST_EXPECT_NO_ERROR (PKIX_ProcessingParams_SetPolicyQualifiersRejected (goodObject, rejected, plContext)); PKIX_TEST_EXPECT_NO_ERROR (PKIX_ProcessingParams_GetPolicyQualifiersRejected (goodObject, &getRejected, plContext)); if (rejected != getRejected) { testError ("GetPolicyQualifiersRejected returned unexpected value"); } cleanup: PKIX_TEST_RETURN(); }
/* * FUNCTION: treeToStringHelper * This function obtains the string representation of a PolicyNode * Tree and compares it to the expected value. * PARAMETERS: * "parent" - a PolicyNode, the root of a PolicyNodeTree; * must be non-NULL. * "expected" - the desired string. * THREAD SAFETY: * Thread Safe * * Multiple threads can safely call this function without worrying * about conflicts, even if they're operating on the same object. * RETURNS: * Nothing. */ static void treeToStringHelper(PKIX_PolicyNode *parent, char *expected) { PKIX_PL_String *stringRep = NULL; char *actual = NULL; PKIX_TEST_STD_VARS(); PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Object_ToString ((PKIX_PL_Object *)parent, &stringRep, plContext)); actual = PKIX_String2ASCII(stringRep, plContext); if (actual == NULL){ pkixTestErrorMsg = "PKIX_String2ASCII Failed"; goto cleanup; } if (PL_strcmp(actual, expected) != 0){ testError("unexpected mismatch"); (void) printf("Actual value:\t%s\n", actual); (void) printf("Expected value:\t%s\n", expected); } cleanup: PKIX_PL_Free(actual, plContext); PKIX_TEST_DECREF_AC(stringRep); PKIX_TEST_RETURN(); }
void Playback::feedMoreData(uint buffer_id) { Sound sound; m_decoder->decode(sound, m_decoder->bytesPerSecond() / 2); uploadToBuffer(sound, buffer_id); alSourceQueueBuffers(m_source_id, 1, &buffer_id); testError("Error while enqueing buffers."); }
/* * Perform NULL wrap, generally expecting an error (either * CSSMERR_CSP_INVALID_KEYATTR_MASK, if the raw key bits should be inaccessible, * or CSSMERR_CSP_INVALID_KEY_REFERENCE, if the key's header has been munged.) */ int nullWrapTest( CSSM_CSP_HANDLE cspHand, CSSM_KEY_PTR key, CSSM_BOOL quiet, CSSM_RETURN expectRtn, const char *keyAlgStr, const char *testStr) { CSSM_CC_HANDLE ccHand; CSSM_RETURN crtn; CSSM_ACCESS_CREDENTIALS creds; CSSM_KEY wrappedKey; // should not get created int irtn; memset(&wrappedKey, 0, sizeof(CSSM_KEY)); memset(&creds, 0, sizeof(CSSM_ACCESS_CREDENTIALS)); crtn = CSSM_CSP_CreateSymmetricContext(cspHand, CSSM_ALGID_NONE, CSSM_ALGMODE_NONE, &creds, // passPhrase, NULL, // wrappingKey, NULL, // IV CSSM_PADDING_NONE, 0, // Params &ccHand); if(crtn) { printError("cspWrapKey/CreateContext", crtn); return testError(quiet); } crtn = CSSM_WrapKey(ccHand, &creds, key, NULL, // DescriptiveData &wrappedKey); if(crtn != expectRtn) { printf("***Testing %s for alg %s:\n", testStr, keyAlgStr); printf(" CSSM_WrapKey: expect %s\n", cssmErrToStr(expectRtn)); printf(" CSSM_WrapKey: got %s\n", cssmErrToStr(crtn)); irtn = testError(quiet); } else { irtn = 0; } CSSM_DeleteContext(ccHand); return irtn; }
void kappaMapFromKappa(gal_map *gMap, map_t *kMap, error **err) { testError(gMap->length!=kMap->length, peak_match, "Resolution match error", *err, __LINE__); forwardError(*err, __LINE__,); int i; for (i=0; i<gMap->length; i++) kMap->kappa[i] = kappaMean_gal_list(gMap->map[i], err); forwardError(*err, __LINE__,); kMap->type = kappa_map; return; }