-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit tests for query_initialized #45
Open
parkerha1
wants to merge
2
commits into
openshmem-org:main
Choose a base branch
from
parkerha1:query_initialized
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright (c) 2024 Intel Corporation. All rights reserved. | ||
* This software is available to you under the BSD license below: | ||
* | ||
* Redistribution and use in source and binary forms, with or | ||
* without modification, are permitted provided that the following | ||
* conditions are met: | ||
* | ||
* - Redistributions of source code must retain the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer. | ||
* | ||
* - Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials | ||
* provided with the distribution. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <shmem.h> | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
int initialized; | ||
int init_count = 3; | ||
int finalize_count = 3; | ||
int inits_done = 0; | ||
int finalizes_done = 0; | ||
|
||
// Check if SHMEM is initialized before calling init | ||
shmem_query_initialized(&initialized); | ||
if (initialized != 0) { | ||
printf("ERR: Query_initialized not initially returning 0\n"); | ||
return 1; | ||
} | ||
|
||
// Initialize SHMEM multiple times | ||
for (int i = 0; i < init_count; i++) { | ||
shmem_init(); | ||
inits_done++; | ||
|
||
shmem_query_initialized(&initialized); | ||
if (initialized == 0) { | ||
printf("ERR: Initialization failed on iteration %d\n", i + 1); | ||
return 1; | ||
} | ||
} | ||
|
||
// Finalize SHMEM multiple times | ||
for (int i = 0; i < finalize_count; i++) { | ||
shmem_finalize(); | ||
finalizes_done++; | ||
|
||
shmem_query_initialized(&initialized); | ||
|
||
if (inits_done > finalizes_done && initialized == 0) { | ||
printf("ERR: SHMEM should still be initialized after finalize iteration %d\n", i + 1); | ||
return 1; | ||
} else if (initialized != 0) { | ||
printf("ERR: SHMEM should be finalized after finalize iteration %d\n", i + 1); | ||
return 1; | ||
} | ||
} | ||
|
||
// Verify that init can be called again after finalizing | ||
shmem_init(); | ||
shmem_query_initialized(&initialized); | ||
if (initialized == 0) { | ||
printf("ERR: Re-initialization failed after finalization. Expected SHMEM to be initialized again.\n"); | ||
return 1; | ||
} | ||
|
||
shmem_finalize(); | ||
return 0; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should probably be
shmemx_query_initialized
... At least for tests-sos v1.5.x.If we go that route, then this test wouldn't build against your SOS implementation of course, but I think that's ok temporarily during our transition to v1.6.x.
I think let's keep the test this way (
shmem_
) until we are ready to merge Sandia-OpenSHMEM/SOS#1144. Then we can test against this? Although, I'm not certain our CI covers shmemx very well... will have to check.Sorry for the confusion...