Skip to content

Commit 67d4045

Browse files
committed
small fixes to tests
1 parent ea2ea3b commit 67d4045

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

flang/runtime/extensions.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,16 @@ void FORTRAN_PROCEDURE_NAME(getarg)(
8080
n, &value, nullptr, nullptr, __FILE__, __LINE__);
8181
}
8282

83+
// CALL GETLOG(USRNAME)
8384
void FORTRAN_PROCEDURE_NAME(getlog)(std::int8_t *arg, std::int64_t length) {
8485
const int nameMaxLen{LOGIN_NAME_MAX + 1};
8586
char str[nameMaxLen];
8687

8788
int error{getlogin_r(str, nameMaxLen)};
8889
Terminator terminator{__FILE__, __LINE__};
89-
RUNTIME_CHECK(terminator, error == 0);
90+
if (error != 0) {
91+
terminator.Crash("getlogin_r fail with a nonzero value: %d.\n", error);
92+
}
9093

9194
// find first \0 in string then pad from there
9295
CopyAndPad(reinterpret_cast<char *>(arg), str, length, std::strlen(str));

flang/unittests/Runtime/ExtensionTest.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
#include <cstdlib>
1717

1818
#ifdef _WIN32
19-
#include <lmcons.h> // UNLEN=256
19+
#include <lmcons.h> // UNLEN
2020
#define LOGIN_NAME_MAX UNLEN
2121
#else
22-
#include <limits.h>
22+
#include <limits.h> // LOGIN_NAME_MAX
2323
#endif
2424

2525
using namespace Fortran::runtime;
@@ -37,8 +37,9 @@ TEST_F(ExtensionTests, GetlogGetName) {
3737
}
3838

3939
TEST_F(ExtensionTests, GetlogPadSpace) {
40-
const int charLen{LOGIN_NAME_MAX +
41-
2}; // guarantee 1 char longer than max, last char should be pad space
40+
// guarantee 1 char longer than max, last char should be pad with space
41+
const int charLen{LOGIN_NAME_MAX + 2};
42+
4243
char input[charLen];
4344

4445
FORTRAN_PROCEDURE_NAME(getlog)

0 commit comments

Comments
 (0)