Skip to content

Commit

Permalink
Merge pull request #182 from grondo/musl-portability
Browse files Browse the repository at this point in the history
port to musl and add alpine CI build
  • Loading branch information
mergify[bot] authored Nov 17, 2023
2 parents 446d6bd + 30b82cb commit 4c0ccb6
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Required
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.11"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: doc/conf.py
Expand Down
2 changes: 1 addition & 1 deletion src/imp/exec/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <errno.h>
#include <assert.h>
#include <sys/types.h>
#include <wait.h>
#include <sys/wait.h>
#include <jansson.h>

#include "src/libutil/kv.h"
Expand Down
6 changes: 6 additions & 0 deletions src/imp/pidinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
#ifdef HAVE_LINUX_MAGIC_H
#include <linux/magic.h>
#endif
#ifndef TMPFS_MAGIC
#define TMPFS_MAGIC 0x01021994 /* from linux/magic.h */
#endif
#ifndef CGROUP_SUPER_MAGIC
#define CGROUP_SUPER_MAGIC 0x27e0eb
#endif

#include <pwd.h>
#include <signal.h>
Expand Down
2 changes: 1 addition & 1 deletion src/imp/test/pidinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <wait.h>
#include <sys/wait.h>
#include <unistd.h>
#include <string.h>

Expand Down
2 changes: 2 additions & 0 deletions src/lib/sign.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#ifndef _FLUX_SECURITY_SIGN_H
#define _FLUX_SECURITY_SIGN_H

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand Down
12 changes: 10 additions & 2 deletions src/libutil/test/cf.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <limits.h>
#include <errno.h>
#include <jansson.h>
#include <glob.h>

#include "src/libtap/tap.h"
#include "cf.h"
Expand Down Expand Up @@ -79,7 +80,7 @@ static time_t strtotime (const char *s)
{
struct tm tm;
time_t t;
if (!strptime (s, "%FT%TZ", &tm))
if (!strptime (s, "%Y-%m-%dT%TZ", &tm))
BAIL_OUT ("strptime: %s failed", s);
if ((t = timegm (&tm)) < 0)
BAIL_OUT ("timegm: %s failed", s);
Expand Down Expand Up @@ -528,6 +529,7 @@ void test_update_glob (void)
char path3[PATH_MAX + 1];
char invalid[PATH_MAX + 1];
char p [8192];
glob_t gl;

cf_t *cf;
const cf_t *cf2, *cf3;
Expand Down Expand Up @@ -567,18 +569,24 @@ void test_update_glob (void)
ok ((cf3 = cf_get_in (cf, "tab3")) != NULL,
"found tab3 table in cf");


errno = 0;
ok ((cf_update_glob (cf, "/noexist*", &error) == 0),
"cf_update_glob returns 0 on no match");
diag ("%s: %d: %s", error.filename, error.lineno, error.errbuf);
like (error.errbuf, "[nN]o [mM]atch", "got expected error text");


/* Only run the following tests if this implementation of glob(3)
* returns GLOB_ABORTED when parent dir does not exist. This occurs
* for example on the musl libc version of glob(3).
*/
skip (glob ("/noexist/*", GLOB_ERR, NULL, &gl) != GLOB_ABORTED, 2);
errno = 0;
ok ((cf_update_glob (cf, "/noexist/*", &error) < 0) && errno == EINVAL,
"cf_update_glob fails on read error");
diag ("%s: %d: %s", error.filename, error.lineno, error.errbuf);
like (error.errbuf, "[rR]ead [eE]rror", "got expected error text");
end_skip;

cf_destroy (cf);

Expand Down
2 changes: 1 addition & 1 deletion src/libutil/test/tomltk.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static bool check_ts (json_t *ts, const char *timestr)
return false;
if (!gmtime_r (&t, &tm))
return false;
if (strftime (buf, sizeof (buf), "%FT%TZ", &tm) == 0)
if (strftime (buf, sizeof (buf), "%Y-%m-%dT%TZ", &tm) == 0)
return false;
diag ("%s: %s ?= %s", __FUNCTION__, buf, timestr);
return !strcmp (buf, timestr);
Expand Down
4 changes: 2 additions & 2 deletions src/libutil/timestamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int timestamp_tostr (time_t t, char *buf, int size)
struct tm tm;
if (t < 0 || !gmtime_r (&t, &tm))
return -1;
if (strftime (buf, size, "%FT%TZ", &tm) == 0)
if (strftime (buf, size, "%Y-%m-%dT%TZ", &tm) == 0)
return -1;
return 0;
}
Expand All @@ -30,7 +30,7 @@ int timestamp_fromstr (const char *s, time_t *tp)
{
struct tm tm;
time_t t;
if (!strptime (s, "%FT%TZ", &tm))
if (!strptime (s, "%Y-%m-%dT%TZ", &tm))
return -1;
if ((t = timegm (&tm)) < 0)
return -1;
Expand Down
7 changes: 7 additions & 0 deletions src/test/generate-matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,11 @@ def __str__(self):
args="--enable-sanitizers",
pam=False, # asan not compatible with PAM tests
)

# alpine
matrix.add_build(
name="alpine",
image="alpine",
)

print(matrix)
6 changes: 2 additions & 4 deletions t/src/getpwuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,20 @@
struct passwd *getpwuid (uid_t uid)
{
const char *filename;
static char buf[4096];
static struct passwd pw;
struct passwd *pwp = NULL;

if ((filename = getenv ("TEST_PASSWD_FILE"))) {
FILE *f;
if ((f = fopen (filename, "r"))) {
while (fgetpwent_r (f, &pw, buf, sizeof (buf), &pwp) == 0) {
while ((pwp = fgetpwent (f))) {
if (pwp->pw_uid == uid)
break;
}
(void)fclose (f);
}
}
else
getpwuid_r (uid, &pw, buf, sizeof (buf), &pwp);
pwp = getpwuid (uid);

if (pwp == NULL)
errno = ENOENT;
Expand Down
1 change: 1 addition & 0 deletions t/src/sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdint.h>

#include "src/lib/context.h"
#include "src/lib/sign.h"
Expand Down

0 comments on commit 4c0ccb6

Please sign in to comment.