Skip to content
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

Scheduler: add <min_libc_version> option to plan_class_spec.xml #5323

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
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
29 changes: 29 additions & 0 deletions sched/plan_class_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@
return 0;
}

// if os_version has [...|libc 2.27 ...], return 227. else 0
//
static int libc_version(HOST &h) {
char *p = strstr(h.os_version, "|libc ");

Check warning on line 86 in sched/plan_class_spec.cpp

View check run for this annotation

Codecov / codecov/patch

sched/plan_class_spec.cpp#L86

Added line #L86 was not covered by tests
if (!p) return 0;
p += strlen("|libc ");

Check warning on line 88 in sched/plan_class_spec.cpp

View check run for this annotation

Codecov / codecov/patch

sched/plan_class_spec.cpp#L88

Added line #L88 was not covered by tests
int maj, min;
int n = sscanf(p, "%d.%d", &maj, &min);

Check warning on line 90 in sched/plan_class_spec.cpp

View check run for this annotation

Codecov / codecov/patch

sched/plan_class_spec.cpp#L90

Added line #L90 was not covered by tests
if (n != 2) return 0;
return maj*100+min;

Check warning on line 92 in sched/plan_class_spec.cpp

View check run for this annotation

Codecov / codecov/patch

sched/plan_class_spec.cpp#L92

Added line #L92 was not covered by tests
}

// parse version# from "(Android 4.3.1)" or "(Android 4.3)" or "(Android 4)"
//
static int android_version_num(HOST h) {
Expand Down Expand Up @@ -383,6 +395,21 @@
}
}

// libc version (linux)
//
if (min_libc_version) {
int v = libc_version(sreq.host);

Check warning on line 401 in sched/plan_class_spec.cpp

View check run for this annotation

Codecov / codecov/patch

sched/plan_class_spec.cpp#L401

Added line #L401 was not covered by tests
if (v < min_libc_version) {
if (config.debug_version_select) {
log_messages.printf(MSG_NORMAL,

Check warning on line 404 in sched/plan_class_spec.cpp

View check run for this annotation

Codecov / codecov/patch

sched/plan_class_spec.cpp#L404

Added line #L404 was not covered by tests
"[version] plan_class_spec: libc version too low (%d < %d)\n",
v, min_libc_version
);
}
return false;

Check warning on line 409 in sched/plan_class_spec.cpp

View check run for this annotation

Codecov / codecov/patch

sched/plan_class_spec.cpp#L409

Added line #L409 was not covered by tests
}
}

// CPU vendor and model
//
if (have_cpu_vendor_regex && regexec(&(cpu_vendor_regex), sreq.host.p_vendor, 0, NULL, 0)) {
Expand Down Expand Up @@ -1099,6 +1126,7 @@
if (xp.parse_double("max_os_version", max_os_version)) continue;
if (xp.parse_int("min_android_version", min_android_version)) continue;
if (xp.parse_int("max_android_version", max_android_version)) continue;
if (xp.parse_int("min_libc_version", min_libc_version)) continue;
if (xp.parse_str("project_prefs_tag", project_prefs_tag, sizeof(project_prefs_tag))) continue;
if (xp.parse_str("project_prefs_regex", buf, sizeof(buf))) {
if (regcomp(&(project_prefs_regex), buf, REG_EXTENDED|REG_NOSUB) ) {
Expand Down Expand Up @@ -1201,6 +1229,7 @@
max_os_version = 0;
min_android_version = 0;
max_android_version = 0;
min_libc_version = 0;

Check warning on line 1232 in sched/plan_class_spec.cpp

View check run for this annotation

Codecov / codecov/patch

sched/plan_class_spec.cpp#L1232

Added line #L1232 was not covered by tests
strcpy(project_prefs_tag, "");
have_project_prefs_regex = false;
project_prefs_default_true = false;
Expand Down
3 changes: 2 additions & 1 deletion sched/plan_class_spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <regex.h>

// Represents a plan class, as specified in XML
// if you add anything here, initialize if in the constructor
// if you add anything here, initialize it in the constructor
//
struct PLAN_CLASS_SPEC {
char name[256];
Expand Down Expand Up @@ -51,6 +51,7 @@ struct PLAN_CLASS_SPEC {
double max_os_version;
int min_android_version;
int max_android_version;
int min_libc_version;
char project_prefs_tag[256];
bool have_project_prefs_regex;
regex_t project_prefs_regex;
Expand Down
Loading