Skip to content

v3.0.x: fix opal NFS test #4180

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

Merged
merged 1 commit into from
Sep 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions test/util/opal_path_nfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* All rights reserved.
* Copyright (c) 2010 Oak Ridge National Laboratory.
* All rights reserved.
* Copyright (c) 2010-2014 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2010-2017 Cisco Systems, Inc. All rights reserved
* Copyright (c) 2010 IBM Corporation. All rights reserved.
* Copyright (c) 2014 Los Alamos National Security, LLC. All rights
* reserved.
Expand Down Expand Up @@ -132,7 +132,6 @@ void test(char* file, bool expect)

void get_mounts (int * num_dirs, char ** dirs[], bool * nfs[])
{
#define MAX_DIR 256
#define SIZE 1024
char * cmd = "mount | cut -f3,5 -d' ' > opal_path_nfs.out";
int rc;
Expand All @@ -150,13 +149,31 @@ void get_mounts (int * num_dirs, char ** dirs[], bool * nfs[])
**dirs = NULL;
*nfs = NULL;
}
dirs_tmp = (char**) calloc (MAX_DIR, sizeof(char**));
nfs_tmp = (bool*) malloc (MAX_DIR * sizeof(bool));

/* First, count how many mount points there are. Previous
versions of this test tried to have a (large) constant-sized
array for the mount points, but periodically it would break
because we would run this test on a system with a larger number
of mount points than the array. So just count and make sure to
have an array large enough. */
file = fopen("opal_path_nfs.out", "r");
int count = 0;
while (NULL != fgets (buffer, SIZE, file)) {
++count;
}
printf("Found %d mounts\n", count);

// Add one more so we can have a NULL entry at the end
++count;

dirs_tmp = (char**) calloc (count, sizeof(char*));
nfs_tmp = (bool*) calloc (count, sizeof(bool));

i = 0;
rc = 4711;
while (NULL != fgets (buffer, SIZE, file)) {
rewind(file);
// i should never be more than count, but be safe anyway.
while (i < count && NULL != fgets (buffer, SIZE, file)) {
int mount_known;
char fs[MAXNAMLEN];

Expand Down