| /////////////////////////////////////////////////////////////////////////////// |
| // Copyright (c) 2000-2019 Ericsson Telecom AB // |
| // // |
| // All rights reserved. This program and the accompanying materials // |
| // are made available under the terms of the Eclipse Public License v2.0 // |
| // which accompanies this distribution, and is available at // |
| // https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html // |
| /////////////////////////////////////////////////////////////////////////////// |
| //////////////////////////////////////////////////////////////// |
| |
| /////////////////////////////////////////////////////////// |
| // Module: EPTF_Semaphore_Test_Testcases |
| // |
| // Purpose: |
| // This module contains the testcases of generic EPTF Semaphore feture |
| // |
| // Module depends on: |
| // <EPTF_Variable_Test_Definitions> |
| // <EPTF_Semaphore_Test_Functions> |
| // <EPTF_CLL_Semaphore_Functions> |
| // <EPTF_CLL_Base_Functions> |
| // <EPTF_CLL_Base_Functions> |
| // |
| // |
| // Current Owner: |
| // Balazs Barcsik (EBALBAR) |
| // |
| // Last Review Date: |
| // 2007-xx-xx |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////////// |
| module EPTF_Semaphore_Test_Testcases { |
| |
| //========================================================================= |
| // Import Part |
| //========================================================================= |
| import from EPTF_Semaphore_Test_Definitions all; |
| import from EPTF_Semaphore_Test_Functions all; |
| import from EPTF_CLL_Semaphore_Functions all; |
| import from EPTF_CLL_Base_Functions all; |
| |
| //========================================================================= |
| // Testcases |
| //========================================================================= |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Semaphore_Test_init_CT |
| // |
| // Purpose: |
| // to test basic functionality of EPTF_Semaphore |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - calls f_EPTF_Semaphore_init_CT() function |
| // - creates two semaphores, one of them will be locked, the other is not. |
| // - it is checked if f_EPTF_Semaphore_waitForUnlock returns true for the semaphore |
| // which is never unlocked after the timeout |
| // - the other semaphore is then unlocked |
| // - it is checked that the f_EPTF_Semaphore_waitForUnlock returns false for this semaphore |
| // |
| // Expected Result: |
| // testcase runs properly |
| /////////////////////////////////////////////////////////// |
| testcase tc_Semaphore_basicTest() runs on EPTF_Semaphore_Test_CT { |
| f_EPTF_Semaphore_init_CT("Semaphore_Test"); |
| v_semaphoreIdx := f_EPTF_Semaphore_new(); |
| v_semaphoreIdx2 := f_EPTF_Semaphore_new(); |
| t_lock.start; |
| var default v_def := activate(as_Semaphore_test_default()); |
| |
| log("Waiting for unlock......"); |
| if (f_EPTF_Semaphore_waitForUnlock(v_semaphoreIdx)) { |
| setverdict(fail); |
| } |
| setverdict(pass) |
| log("blocking finished"); |
| f_EPTF_Base_cleanup_CT(); |
| deactivate(v_def); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Semaphore_Test_init_CT |
| // |
| // Purpose: |
| // to test f_EPTF_Semaphore_init_CT() function |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - calls f_EPTF_Semaphore_init_CT() function |
| // - calls f_EPTF_Semaphore_new() function |
| // - calls f_EPTF_Semaphore_delete() function |
| // |
| // Expected Result: |
| // testcase runs properly |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_Semaphore_Test_init_CT() runs on EPTF_Semaphore_Test_CT { |
| |
| f_EPTF_Semaphore_init_CT("Semaphore_Test"); |
| v_semaphoreIdx := f_EPTF_Semaphore_new(); |
| f_EPTF_Semaphore_delete(v_semaphoreIdx); |
| setverdict(pass); |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Semaphore_Test_new |
| // |
| // Purpose: |
| // to test f_EPTF_Semaphore_new() function |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - calls f_EPTF_Semaphore_init_CT() function |
| // - calls f_EPTF_Semaphore_new() function twice |
| // - matches the returned semaphore indexes |
| // |
| // Expected Result: |
| // indexes not equal |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_Semaphore_Test_new() runs on EPTF_Semaphore_Test_CT { |
| f_EPTF_Semaphore_init_CT("Semaphore_Test"); |
| v_semaphoreIdx := f_EPTF_Semaphore_new(); |
| v_semaphoreIdx2 := f_EPTF_Semaphore_new(); |
| if (v_semaphoreIdx2 != v_semaphoreIdx) { |
| setverdict(pass); |
| } else { |
| log("Error: created semaphore indexes are equal: ", v_semaphoreIdx, " - ", v_semaphoreIdx2); |
| } |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Semaphore_Test_delete |
| // |
| // Purpose: |
| // to test f_EPTF_Semaphore_delete() function |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - calls f_EPTF_Semaphore_init_CT() function |
| // - calls f_EPTF_Semaphore_new() function |
| // - calls f_EPTF_Semaphore_unlock() function |
| // - calls f_EPTF_Semaphore_delete() function |
| // |
| // Expected Result: |
| // testcase runs properly |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_Semaphore_Test_delete() runs on EPTF_Semaphore_Test_CT { |
| f_EPTF_Semaphore_init_CT("Semaphore_Test"); |
| v_semaphoreIdx := f_EPTF_Semaphore_new(); |
| f_EPTF_Semaphore_unlock(v_semaphoreIdx); |
| f_EPTF_Semaphore_delete(v_semaphoreIdx); |
| // f_EPTF_Semaphore_delete(v_semaphoreIdx + 1); |
| setverdict(pass); |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Semaphore_Test_lock |
| // |
| // Purpose: |
| // to test f_EPTF_Semaphore_lock() function |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - calls f_EPTF_Semaphore_init_CT() function |
| // - calls f_EPTF_Semaphore_new() function |
| // - calls f_EPTF_Semaphore_waitForUnlock() function |
| // - after f_EPTF_Semaphore_waitForUnlock() function returns, checks the locking time |
| // - calls f_EPTF_Semaphore_new() function |
| // - calls f_EPTF_Semaphore_unlock() function |
| // - calls f_EPTF_Semaphore_lock() function |
| // - calls f_EPTF_Semaphore_waitForUnlock() function with an expired time |
| // - checks that f_EPTF_Semaphore_waitForUnlock() function returns with true after expired time |
| // Expected Result: |
| // - f_EPTF_Semaphore_waitForUnlock() function returns after the expected time |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_Semaphore_Test_lock() runs on EPTF_Semaphore_Test_CT { |
| |
| timer tl_wait; |
| var float vl_setUnlockTime := 2.0; |
| var float vl_getUnlockTime; |
| var default v_def := activate(as_EPTF_Semaphore_Test_lock()); |
| |
| f_EPTF_Semaphore_init_CT("Semaphore_Test"); |
| v_semaphoreIdx := f_EPTF_Semaphore_new(); |
| tl_wait.start(10.0); |
| t_lock.start(vl_setUnlockTime); |
| |
| if (not f_EPTF_Semaphore_waitForUnlock(v_semaphoreIdx)) { |
| setverdict(pass); |
| } else { |
| log("Error: f_EPTF_Semaphore_waitForUnlock() returns with true"); |
| setverdict(fail); |
| } |
| vl_getUnlockTime := tl_wait.read; |
| tl_wait.stop; |
| if (vl_getUnlockTime >= vl_setUnlockTime and vl_getUnlockTime < vl_setUnlockTime + 0.01) { |
| setverdict(pass); |
| } else { |
| log("Error: wrong locking interval: ", vl_getUnlockTime, ", expected: ", vl_setUnlockTime); |
| } |
| vl_setUnlockTime := 1.0; |
| v_semaphoreIdx := f_EPTF_Semaphore_new(); |
| f_EPTF_Semaphore_unlock(v_semaphoreIdx); |
| f_EPTF_Semaphore_lock(v_semaphoreIdx); |
| tl_wait.start(10.0); |
| |
| if (f_EPTF_Semaphore_waitForUnlock(v_semaphoreIdx, vl_setUnlockTime)) { |
| setverdict(pass); |
| } else { |
| log("Error: f_EPTF_Semaphore_waitForUnlock() returns with true"); |
| setverdict(fail); |
| } |
| vl_getUnlockTime := tl_wait.read; |
| tl_wait.stop; |
| if (vl_getUnlockTime >= vl_setUnlockTime and vl_getUnlockTime < vl_setUnlockTime + 0.01) { |
| setverdict(pass); |
| } else { |
| log("Error: wrong blocking interval: ", vl_getUnlockTime, ", expected: ", vl_setUnlockTime); |
| } |
| //f_EPTF_Semaphore_lock(v_semaphoreIdx + 10); |
| f_EPTF_Base_cleanup_CT(); |
| deactivate(v_def); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Semaphore_Test_unlock |
| // |
| // Purpose: |
| // to test f_EPTF_Semaphore_unlock() function |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - calls f_EPTF_Semaphore_init_CT() function |
| // - calls f_EPTF_Semaphore_new() function |
| // - calls f_EPTF_Semaphore_unlock() function |
| // - calls f_EPTF_Semaphore_waitForUnlock() function |
| // - checks the return value of f_EPTF_Semaphore_waitForUnlock function |
| // Expected Result: |
| // - f_EPTF_Semaphore_waitForUnlock() function returns false, because semafore allready unlocked |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_Semaphore_Test_unlock() runs on EPTF_Semaphore_Test_CT { |
| |
| |
| f_EPTF_Semaphore_init_CT("Semaphore_Test"); |
| v_semaphoreIdx := f_EPTF_Semaphore_new(); |
| |
| f_EPTF_Semaphore_unlock(v_semaphoreIdx); |
| if (not f_EPTF_Semaphore_waitForUnlock(v_semaphoreIdx)) { |
| setverdict(pass); |
| } else { |
| log("Error: semaphore still locked: ", v_semaphoreIdx); |
| setverdict(fail); |
| } |
| //f_EPTF_Semaphore_unlock(v_semaphoreIdx + 1); |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Semaphore_Test_multiLockMultiUnlock |
| // |
| // Purpose: |
| // to test f_EPTF_Semaphore_increaseLock(), f_EPTF_Semaphore_decreaseLock() functions |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - creates a semaphore and set its lock level to 3 |
| // - activates an altstep which will decrease its lock level by 3 |
| // using the f_EPTF_Semaphore_decreaseLock() function |
| // - calls f_EPTF_Semaphore_waitForUnlock() function |
| // - checks the return value of f_EPTF_Semaphore_waitForUnlock function |
| // - checks the elapsed time until unlock |
| // |
| // Expected Result: |
| // - f_EPTF_Semaphore_waitForUnlock() function returns false, because semaphore will be unlocked |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_Semaphore_Test_multiLockMultiUnlock() runs on EPTF_Semaphore_Test_CT { |
| |
| f_EPTF_Semaphore_init_CT("Semaphore_Test"); |
| v_semaphoreIdx := f_EPTF_Semaphore_new(); |
| |
| f_EPTF_Semaphore_unlock(v_semaphoreIdx); // set to lock-level 0 |
| f_EPTF_Semaphore_increaseLock(v_semaphoreIdx); |
| f_EPTF_Semaphore_increaseLock(v_semaphoreIdx); |
| f_EPTF_Semaphore_increaseLock(v_semaphoreIdx); // lock level is now 3 |
| |
| var float vl_setUnlockTime := 2.0; |
| var float vl_getUnlockTime; |
| var default v_def := activate(as_EPTF_Semaphore_Test_multiLock()); // will call f_EPTF_Semaphore_decreaseLock 3 times |
| |
| timer tl_wait; |
| tl_wait.start(10.0); |
| t_lock.start(vl_setUnlockTime); |
| |
| if (not f_EPTF_Semaphore_waitForUnlock(v_semaphoreIdx,3.0)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail,"Error: semaphore was not unlocked in time: ", v_semaphoreIdx); |
| f_EPTF_Base_stopAll(none); |
| } |
| |
| vl_getUnlockTime := tl_wait.read; |
| tl_wait.stop; |
| if (vl_getUnlockTime >= vl_setUnlockTime and vl_getUnlockTime < vl_setUnlockTime + 0.01) { |
| setverdict(pass); |
| } else { |
| setverdict(fail,"Error: wrong blocking interval: ", vl_getUnlockTime, ", expected: ", vl_setUnlockTime); |
| f_EPTF_Base_stopAll(none); |
| } |
| |
| //f_EPTF_Semaphore_unlock(v_semaphoreIdx + 1); |
| f_EPTF_Base_cleanup_CT(); |
| deactivate(v_def); |
| } |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Semaphore_Test_multiLockUnlock |
| // |
| // Purpose: |
| // to test f_EPTF_Semaphore_increaseLock(), f_EPTF_Semaphore_unlock() functions |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - creates a semaphore and set its lock level to 3 |
| // - activates an altstep which will decrease its lock level to zero |
| // using the f_EPTF_Semaphore_unlock() function |
| // - calls f_EPTF_Semaphore_waitForUnlock() function |
| // - checks the return value of f_EPTF_Semaphore_waitForUnlock function |
| // - checks the elapsed time until unlock |
| // |
| // Expected Result: |
| // - f_EPTF_Semaphore_waitForUnlock() function returns false, because semaphore will be unlocked |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_Semaphore_Test_multiLockUnlock() runs on EPTF_Semaphore_Test_CT { |
| |
| f_EPTF_Semaphore_init_CT("Semaphore_Test"); |
| v_semaphoreIdx := f_EPTF_Semaphore_new(); |
| |
| f_EPTF_Semaphore_increaseLock(v_semaphoreIdx); |
| f_EPTF_Semaphore_increaseLock(v_semaphoreIdx); |
| f_EPTF_Semaphore_increaseLock(v_semaphoreIdx); // lock level is now 4! |
| |
| var float vl_setUnlockTime := 2.0; |
| var float vl_getUnlockTime; |
| var default v_def := activate(as_EPTF_Semaphore_Test_lock()); // will call f_EPTF_Semaphore_unlock |
| |
| timer tl_wait; |
| tl_wait.start(10.0); |
| t_lock.start(vl_setUnlockTime); |
| |
| if (not f_EPTF_Semaphore_waitForUnlock(v_semaphoreIdx,3.0)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail,"Error: semaphore was not unlocked in time: ", v_semaphoreIdx); |
| f_EPTF_Base_stopAll(none); |
| } |
| |
| vl_getUnlockTime := tl_wait.read; |
| tl_wait.stop; |
| if (vl_getUnlockTime >= vl_setUnlockTime and vl_getUnlockTime < vl_setUnlockTime + 0.01) { |
| setverdict(pass); |
| } else { |
| setverdict(fail,"Error: wrong blocking interval: ", vl_getUnlockTime, ", expected: ", vl_setUnlockTime); |
| f_EPTF_Base_stopAll(none); |
| } |
| |
| //f_EPTF_Semaphore_unlock(v_semaphoreIdx + 1); |
| f_EPTF_Base_cleanup_CT(); |
| deactivate(v_def); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Semaphore_Test_waitForUnlockNoDelete |
| // |
| // Purpose: |
| // to test if semaphore can be reused after f_EPTF_Semaphore_waitForUnlock() |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - creates a semaphore and set its lock level to 3 |
| // - activates an altstep which will decrease its lock level to zero |
| // using the f_EPTF_Semaphore_unlock() function |
| // - calls f_EPTF_Semaphore_waitForUnlock() function with auto-delete disabled |
| // - checks the return value of f_EPTF_Semaphore_waitForUnlock function |
| // - checks the elapsed time until unlock |
| // - repeates the above steps for the same semaphore (it is not deleted) |
| // - deletes the semaphore |
| // |
| // Expected Result: |
| // - f_EPTF_Semaphore_waitForUnlock() function returns false, because semaphore will be unlocked |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_Semaphore_Test_waitForUnlockNoDelete() runs on EPTF_Semaphore_Test_CT { |
| |
| f_EPTF_Semaphore_init_CT("Semaphore_Test"); |
| v_semaphoreIdx := f_EPTF_Semaphore_new(); |
| |
| f_EPTF_Semaphore_increaseLock(v_semaphoreIdx); |
| f_EPTF_Semaphore_increaseLock(v_semaphoreIdx); |
| f_EPTF_Semaphore_increaseLock(v_semaphoreIdx); // lock level is now 4! |
| |
| var float vl_setUnlockTime := 2.0; |
| var float vl_getUnlockTime; |
| var default v_def := activate(as_EPTF_Semaphore_Test_lock()); // will call f_EPTF_Semaphore_unlock |
| |
| timer tl_wait; |
| tl_wait.start(10.0); |
| t_lock.start(vl_setUnlockTime); |
| |
| if (not f_EPTF_Semaphore_waitForUnlock(v_semaphoreIdx,3.0,false)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail,"Error: semaphore was not unlocked in time: ", v_semaphoreIdx); |
| f_EPTF_Base_stopAll(none); |
| } |
| |
| vl_getUnlockTime := tl_wait.read; |
| tl_wait.stop; |
| if (vl_getUnlockTime >= vl_setUnlockTime and vl_getUnlockTime < vl_setUnlockTime + 0.01) { |
| setverdict(pass); |
| } else { |
| setverdict(fail,"Error: wrong blocking interval: ", vl_getUnlockTime, ", expected: ", vl_setUnlockTime); |
| f_EPTF_Base_stopAll(none); |
| } |
| |
| // now reuse the same semaphore: |
| f_EPTF_Semaphore_increaseLock(v_semaphoreIdx); |
| f_EPTF_Semaphore_increaseLock(v_semaphoreIdx); |
| f_EPTF_Semaphore_increaseLock(v_semaphoreIdx); // lock level is now 4! |
| |
| tl_wait.start(10.0); |
| t_lock.start(vl_setUnlockTime); |
| |
| if (not f_EPTF_Semaphore_waitForUnlock(v_semaphoreIdx,3.0,false)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail,"Error: reused semaphore was not unlocked in time: ", v_semaphoreIdx); |
| f_EPTF_Base_stopAll(none); |
| } |
| |
| vl_getUnlockTime := tl_wait.read; |
| tl_wait.stop; |
| if (vl_getUnlockTime >= vl_setUnlockTime and vl_getUnlockTime < vl_setUnlockTime + 0.01) { |
| setverdict(pass); |
| } else { |
| setverdict(fail,"Error: wrong blocking interval after reuse: ", vl_getUnlockTime, ", expected: ", vl_setUnlockTime); |
| f_EPTF_Base_stopAll(none); |
| } |
| |
| f_EPTF_Semaphore_delete(v_semaphoreIdx); |
| |
| f_EPTF_Base_cleanup_CT(); |
| deactivate(v_def); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Semaphore_NEG_Test_waitForUnlockNoDelete |
| // |
| // Purpose: |
| // to test if semaphore cannot be used after f_EPTF_Semaphore_delete |
| // |
| // Requirement: |
| // EPTF_DEBUG should be defined |
| // |
| // Action: |
| // This is a negative test! |
| // - creates a semaphore and set its lock level to 3 |
| // - activates an altstep which will decrease its lock level to zero |
| // using the f_EPTF_Semaphore_unlock() function |
| // - calls f_EPTF_Semaphore_waitForUnlock() function with auto-delete enabled |
| // - checks the return value of f_EPTF_Semaphore_waitForUnlock function |
| // - checks the elapsed time until unlock |
| // - tries to use the deleted semaphore |
| // - deletes the semaphore by f_EPTF_Semaphore_delete |
| // |
| // Expected Result: |
| // - f_EPTF_Semaphore_waitForUnlock() function returns false, because semaphore will be unlocked |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_Semaphore_NEG_Test_waitForUnlockNoDelete() runs on EPTF_Semaphore_Test_CT { |
| |
| f_EPTF_Semaphore_init_CT("Semaphore_Test"); |
| v_semaphoreIdx := f_EPTF_Semaphore_new(); |
| |
| f_EPTF_Base_setExpectedAssertMsg("*f_EPTF_Semaphore_increaseLock: Semaphore is invalid*"); |
| |
| f_EPTF_Semaphore_increaseLock(v_semaphoreIdx); |
| f_EPTF_Semaphore_increaseLock(v_semaphoreIdx); |
| f_EPTF_Semaphore_increaseLock(v_semaphoreIdx); // lock level is now 4! |
| |
| var float vl_setUnlockTime := 2.0; |
| var float vl_getUnlockTime; |
| var default v_def := activate(as_EPTF_Semaphore_Test_lock()); // will call f_EPTF_Semaphore_unlock |
| |
| timer tl_wait; |
| tl_wait.start(10.0); |
| t_lock.start(vl_setUnlockTime); |
| |
| if (not f_EPTF_Semaphore_waitForUnlock(v_semaphoreIdx,3.0, true)) { |
| setverdict(pass); |
| } else { |
| setverdict(fail,"Error: semaphore was not unlocked in time: ", v_semaphoreIdx); |
| f_EPTF_Base_stopAll(none); |
| } |
| |
| vl_getUnlockTime := tl_wait.read; |
| tl_wait.stop; |
| if (vl_getUnlockTime >= vl_setUnlockTime and vl_getUnlockTime < vl_setUnlockTime + 0.01) { |
| setverdict(pass); |
| } else { |
| setverdict(fail,"Error: wrong blocking interval: ", vl_getUnlockTime, ", expected: ", vl_setUnlockTime); |
| f_EPTF_Base_stopAll(none); |
| } |
| |
| // the semaphore was deleted by f_EPTF_Semaphore_waitForUnlock |
| |
| // now try to use the deleted semaphore: |
| f_EPTF_Semaphore_increaseLock(v_semaphoreIdx); |
| f_EPTF_Base_cleanup_CT(); |
| deactivate(v_def); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Semaphore_NEG_Test_useInvalidSemaphoreInWaitForUnlock |
| // |
| // Purpose: |
| // to test if assert message comes up if invalied semaphore is used in f_EPTF_Semaphore_waitForUnlock |
| // |
| // Requirement: |
| // EPTF_DEBUG should be defined |
| // |
| // Action: |
| // This is a negative test! |
| // - creates a semaphore |
| // - calls f_EPTF_Semaphore_waitForUnlock for an invalid semaphore |
| // - deletes the semaphore by f_EPTF_Semaphore_delete |
| // |
| // Expected Result: |
| // - f_EPTF_Semaphore_waitForUnlock() function returns false, because semaphore will be unlocked |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_Semaphore_NEG_Test_useInvalidSemaphoreInWaitForUnlock() runs on EPTF_Semaphore_Test_CT { |
| |
| f_EPTF_Semaphore_init_CT("Semaphore_Test"); |
| |
| f_EPTF_Base_setExpectedAssertMsg("*Semaphore is invalid*"); |
| |
| v_semaphoreIdx := f_EPTF_Semaphore_new(); |
| |
| // uses an invalid index: |
| f_EPTF_Semaphore_waitForUnlock(v_semaphoreIdx+1,3.0, true); |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Semaphore_NEG_Test_useInvalidSemaphoreInUnlock |
| // |
| // Purpose: |
| // to test if assert message comes up if invalied semaphore is used in f_EPTF_Semaphore_unlock |
| // |
| // Requirement: |
| // EPTF_DEBUG should be defined |
| // |
| // Action: |
| // This is a negative test! |
| // - creates a semaphore |
| // - calls f_EPTF_Semaphore_unlock for an invalid semaphore |
| // - deletes the semaphore by f_EPTF_Semaphore_delete |
| // |
| // Expected Result: |
| // - f_EPTF_Semaphore_waitForUnlock() function returns false, because semaphore will be unlocked |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_Semaphore_NEG_Test_useInvalidSemaphoreInUnlock() runs on EPTF_Semaphore_Test_CT { |
| |
| f_EPTF_Semaphore_init_CT("Semaphore_Test"); |
| |
| f_EPTF_Base_setExpectedAssertMsg("*Semaphore is invalid*"); |
| |
| v_semaphoreIdx := f_EPTF_Semaphore_new(); |
| |
| // uses an invalid index: |
| f_EPTF_Semaphore_unlock(v_semaphoreIdx+1); |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_Semaphore_NEG_Test_useInvalidSemaphoreInWaitForIncreaseLock |
| // |
| // Purpose: |
| // to test if assert message comes up if invalied semaphore is used in f_EPTF_Semaphore_increaseLock |
| // |
| // Requirement: |
| // EPTF_DEBUG should be defined |
| // |
| // Action: |
| // This is a negative test! |
| // - creates a semaphore |
| // - calls f_EPTF_Semaphore_increaseLock for an invalid semaphore |
| // - deletes the semaphore by f_EPTF_Semaphore_delete |
| // |
| // Expected Result: |
| // - f_EPTF_Semaphore_waitForUnlock() function returns false, because semaphore will be unlocked |
| // |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_Semaphore_NEG_Test_useInvalidSemaphoreInWaitForIncreaseLock() runs on EPTF_Semaphore_Test_CT { |
| |
| f_EPTF_Semaphore_init_CT("Semaphore_Test"); |
| |
| f_EPTF_Base_setExpectedAssertMsg("*Semaphore is invalid*"); |
| |
| v_semaphoreIdx := f_EPTF_Semaphore_new(); |
| |
| // uses an invalid index: |
| f_EPTF_Semaphore_increaseLock(v_semaphoreIdx+1); |
| |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| control { |
| execute(tc_Semaphore_basicTest()); |
| execute(tc_EPTF_Semaphore_Test_init_CT()); |
| execute(tc_EPTF_Semaphore_Test_new()); |
| execute(tc_EPTF_Semaphore_Test_delete()); |
| execute(tc_EPTF_Semaphore_Test_lock()); |
| execute(tc_EPTF_Semaphore_Test_unlock()); |
| execute(tc_EPTF_Semaphore_Test_multiLockMultiUnlock()); |
| execute(tc_EPTF_Semaphore_Test_multiLockUnlock()); |
| execute(tc_EPTF_Semaphore_Test_waitForUnlockNoDelete()); |
| execute(tc_EPTF_Semaphore_NEG_Test_waitForUnlockNoDelete()); |
| execute(tc_EPTF_Semaphore_NEG_Test_useInvalidSemaphoreInWaitForUnlock()); |
| execute(tc_EPTF_Semaphore_NEG_Test_useInvalidSemaphoreInUnlock()); |
| execute(tc_EPTF_Semaphore_NEG_Test_useInvalidSemaphoreInWaitForIncreaseLock()); |
| } |
| } // end of module |