copy sanitycheck from 2.0-ongoing
git-svn-id: svn://localhost/ardour2/branches/3.0@8624 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
d46766aeff
commit
85b4ff8669
359
tools/sanity_check/main.cpp
Normal file
359
tools/sanity_check/main.cpp
Normal file
@ -0,0 +1,359 @@
|
||||
/*
|
||||
*
|
||||
* program: sanityCheck
|
||||
* file: main.c
|
||||
* author: Todd Naugle
|
||||
* date: 11/17/2010
|
||||
*
|
||||
* Desc: Command line version of the sanity check functions found in jack
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "systemtest.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef int (*testfuncPtr) ();
|
||||
typedef int (*testfuncOpPtr) (string);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
string switchText; // ie -option
|
||||
string swOptionText; // option arguments for just this swtich.
|
||||
string descriptionText; // Help Text on what this does
|
||||
string failureText; // What to say when this test fails
|
||||
bool hasOption; // Set true if this switch has option paramters
|
||||
testfuncPtr functionPtr; // Function to call
|
||||
testfuncOpPtr opFunctionPtr; // Function with option string to call
|
||||
string optionArg; // Storage used to hold any options passed in by the user
|
||||
} testRecord;
|
||||
|
||||
static vector<testRecord> gTestSet;
|
||||
|
||||
static vector<string> gValidSwitchList;
|
||||
static vector<string> gSwitchDescriptionList;
|
||||
|
||||
static vector<string> gSwitchesReceived;
|
||||
|
||||
int
|
||||
ExecuteAll()
|
||||
{
|
||||
bool OK = true;
|
||||
|
||||
OK &= system_user_can_rtprio();
|
||||
|
||||
if (system_has_frequencyscaling()) {
|
||||
OK &= !system_uses_frequencyscaling();
|
||||
}
|
||||
|
||||
OK &= !(system_memlock_amount() == 0);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
HasGroup(string name)
|
||||
{
|
||||
return system_has_group(name.c_str());
|
||||
}
|
||||
|
||||
int
|
||||
IsMemberOfGroup(string name)
|
||||
{
|
||||
return system_user_in_group(name.c_str());
|
||||
}
|
||||
|
||||
int
|
||||
CheckFreqScaling()
|
||||
{
|
||||
bool OK = true;
|
||||
|
||||
if (system_has_frequencyscaling()) {
|
||||
OK &= !system_uses_frequencyscaling();
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
CheckMemoryLocking()
|
||||
{
|
||||
return !(system_memlock_amount() == 0);
|
||||
}
|
||||
|
||||
int
|
||||
PrintUsage()
|
||||
{
|
||||
printf("\n");
|
||||
printf(" sanityCheck - A program to verify proper system settings for use with audio applications (Ardour/Jack/Mixbus).\n");
|
||||
printf("\n");
|
||||
printf(" Usage: sanityCheck [OPTIONS]\n");
|
||||
printf("\n");
|
||||
printf(" Options are as follows:\n");
|
||||
printf("\n");
|
||||
printf("\n");
|
||||
|
||||
vector<testRecord>::iterator itr;
|
||||
|
||||
for (itr = gTestSet.begin(); itr != gTestSet.end(); ++itr) {
|
||||
printf("%20s %s :\t%s\n", (*itr).switchText.c_str(), (*itr).swOptionText.c_str(), (*itr).descriptionText.c_str());
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
DefineSwitches()
|
||||
{
|
||||
testRecord rec;
|
||||
|
||||
// Global switches
|
||||
rec.switchText = "-a";
|
||||
rec.swOptionText = "";
|
||||
rec.descriptionText = "Checks for a working RT system. Same as -rt -freqscaling -memlock";
|
||||
rec.failureText = "";
|
||||
rec.hasOption = false;
|
||||
rec.functionPtr = &ExecuteAll;
|
||||
rec.optionArg = "";
|
||||
gTestSet.push_back(rec);
|
||||
|
||||
rec.switchText = "-h";
|
||||
rec.swOptionText = "";
|
||||
rec.descriptionText = "Print usage";
|
||||
rec.failureText = "";
|
||||
rec.hasOption = false;
|
||||
rec.functionPtr = &PrintUsage;
|
||||
rec.optionArg = "";
|
||||
gTestSet.push_back(rec);
|
||||
|
||||
// Switches for various tests that can be performed.
|
||||
rec.switchText = "-rt";
|
||||
rec.swOptionText = "";
|
||||
rec.descriptionText = "Verfiy that the user can run tasks with realtime priority";
|
||||
rec.failureText = "";
|
||||
rec.hasOption = false;
|
||||
rec.functionPtr = &system_user_can_rtprio;
|
||||
rec.optionArg = "";
|
||||
gTestSet.push_back(rec);
|
||||
|
||||
rec.switchText = "-hasrtlimits";
|
||||
rec.swOptionText = "";
|
||||
rec.descriptionText = "Verfiy the system has a limits.conf and the audio group can use realtime";
|
||||
rec.failureText = "";
|
||||
rec.hasOption = false;
|
||||
rec.functionPtr = &system_has_rtprio_limits_conf;
|
||||
rec.optionArg = "";
|
||||
gTestSet.push_back(rec);
|
||||
|
||||
rec.switchText = "-hasgroup";
|
||||
rec.swOptionText = "<groupname>";
|
||||
rec.descriptionText = "Verfiy that the system has a group named <groupname>";
|
||||
rec.failureText = "";
|
||||
rec.hasOption = true;
|
||||
rec.opFunctionPtr = &HasGroup;
|
||||
rec.optionArg = "";
|
||||
gTestSet.push_back(rec);
|
||||
|
||||
rec.switchText = "-hasaudiogroup";
|
||||
rec.swOptionText = "";
|
||||
rec.descriptionText = "Verfiy that the system has an audio group (audio or jackuser) defined";
|
||||
rec.failureText = "";
|
||||
rec.hasOption = false;
|
||||
rec.functionPtr = &system_has_audiogroup;
|
||||
rec.optionArg = "";
|
||||
gTestSet.push_back(rec);
|
||||
|
||||
rec.switchText = "-memberofgroup";
|
||||
rec.swOptionText = "<groupname>";
|
||||
rec.descriptionText = "Verfiy that the user is a member of the group named <groupname>";
|
||||
rec.failureText = "";
|
||||
rec.hasOption = true;
|
||||
rec.opFunctionPtr = &IsMemberOfGroup;
|
||||
rec.optionArg = "";
|
||||
gTestSet.push_back(rec);
|
||||
|
||||
rec.switchText = "-memberaudiogroup";
|
||||
rec.swOptionText = "";
|
||||
rec.descriptionText = "Verfiy that the user is a member of the audio group (audio or jackuser)";
|
||||
rec.failureText = "";
|
||||
rec.hasOption = false;
|
||||
rec.functionPtr = &system_user_in_audiogroup;
|
||||
rec.optionArg = "";
|
||||
gTestSet.push_back(rec);
|
||||
|
||||
rec.switchText = "-freqscaling";
|
||||
rec.swOptionText = "";
|
||||
rec.descriptionText = "Check to see if frequency scaling is being used by the CPU";
|
||||
rec.failureText = "";
|
||||
rec.hasOption = false;
|
||||
rec.functionPtr = &CheckFreqScaling;
|
||||
rec.optionArg = "";
|
||||
gTestSet.push_back(rec);
|
||||
|
||||
rec.switchText = "-memlock";
|
||||
rec.swOptionText = "";
|
||||
rec.descriptionText = "Check to see if the user is able to lock memory";
|
||||
rec.failureText = "";
|
||||
rec.hasOption = false;
|
||||
rec.functionPtr = &CheckMemoryLocking;
|
||||
rec.optionArg = "";
|
||||
gTestSet.push_back(rec);
|
||||
|
||||
}
|
||||
|
||||
bool
|
||||
ParseSwitches(
|
||||
int argc,
|
||||
char **argv)
|
||||
{
|
||||
string tmp;
|
||||
vector<testRecord>::iterator itr;
|
||||
bool OK = true;
|
||||
int i;
|
||||
|
||||
if (argc == 1) {
|
||||
gSwitchesReceived.push_back("-a");
|
||||
}
|
||||
else {
|
||||
for (i = 1; i < argc && OK == true; i++) {
|
||||
tmp = argv[i];
|
||||
|
||||
for (itr = gTestSet.begin(); itr != gTestSet.end(); ++itr) {
|
||||
if (tmp == (*itr).switchText) {
|
||||
if ((*itr).hasOption == true) {
|
||||
if (++i < argc) {
|
||||
string op = argv[i];
|
||||
if (op[0] == '-') {
|
||||
// reqiured option for this switch is missing
|
||||
--i;
|
||||
OK = false;
|
||||
break;
|
||||
}
|
||||
(*itr).optionArg = op;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// reqiured option for this switch is missing
|
||||
--i;
|
||||
OK = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (OK && itr != gTestSet.end()) {
|
||||
// Known option switch found
|
||||
gSwitchesReceived.push_back(tmp);
|
||||
}
|
||||
else {
|
||||
// Unknown option
|
||||
OK = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (OK) {
|
||||
// All switches are at least valid, now check to make sure they are all valid to
|
||||
// be used together.
|
||||
|
||||
if (gSwitchesReceived.size() > 1) {
|
||||
// make sure help is not mixed with other options
|
||||
vector<string>::iterator swItr;
|
||||
tmp = "-h";
|
||||
|
||||
swItr = find(gSwitchesReceived.begin(), gSwitchesReceived.end(), tmp);
|
||||
|
||||
if (swItr != gSwitchesReceived.end()) {
|
||||
gSwitchesReceived.clear();
|
||||
gSwitchesReceived.push_back("-h");
|
||||
}
|
||||
|
||||
// make sure -a is only used by itself
|
||||
tmp = "-a";
|
||||
swItr = find(gSwitchesReceived.begin(), gSwitchesReceived.end(), tmp);
|
||||
|
||||
if (swItr != gSwitchesReceived.end()) {
|
||||
gSwitchesReceived.clear();
|
||||
gSwitchesReceived.push_back("-a");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "ERROR - Invalid Option: %s\n", (const char *) argv[--i]);
|
||||
fprintf(stderr, "Check syntax\n");
|
||||
PrintUsage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Execute()
|
||||
{
|
||||
bool OK = true;
|
||||
vector<string>::iterator itr;
|
||||
vector<testRecord>::iterator testItr;
|
||||
|
||||
for (itr = gSwitchesReceived.begin(); itr != gSwitchesReceived.end(); ++itr) {
|
||||
for (testItr = gTestSet.begin(); testItr != gTestSet.end(); ++testItr) {
|
||||
if ((*itr) == (*testItr).switchText) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool result;
|
||||
if ((*testItr).hasOption) {
|
||||
result = ((*testItr).opFunctionPtr((*testItr).optionArg) != 0);
|
||||
}
|
||||
else {
|
||||
result = ((*testItr).functionPtr() != 0);
|
||||
}
|
||||
|
||||
if (result == 0) {
|
||||
// Check for a Failure message and print it if found.
|
||||
if (!(*testItr).failureText.empty()) {
|
||||
printf("\n%s\n", (*testItr).failureText.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
OK &= result;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
main(
|
||||
int argc,
|
||||
char **argv)
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
DefineSwitches();
|
||||
|
||||
if (ParseSwitches(argc, argv)) {
|
||||
if (Execute() == false) {
|
||||
printf("\nSanity Check Failed!\n\n");
|
||||
status = -1;
|
||||
}
|
||||
else {
|
||||
printf("\nSanity Check OK!\n\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
status = -1;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
333
tools/sanity_check/systemtest.cpp
Normal file
333
tools/sanity_check/systemtest.cpp
Normal file
@ -0,0 +1,333 @@
|
||||
/**
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* Set of functions to gather system information for the jack setup wizard.
|
||||
*
|
||||
* TODO: Test for rt prio availability
|
||||
*
|
||||
* @author Florian Faber, faber@faberman.de
|
||||
*
|
||||
**/
|
||||
|
||||
/** maximum number of groups a user can be a member of **/
|
||||
#define MAX_GROUPS 100
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <grp.h>
|
||||
|
||||
#include <sched.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "systemtest.h"
|
||||
|
||||
/**
|
||||
* This function checks for the existence of known frequency scaling mechanisms
|
||||
* in this system by testing for the availability of scaling governors/
|
||||
*
|
||||
* @returns 0 if the system has no frequency scaling capabilities non-0 otherwise.
|
||||
**/
|
||||
int system_has_frequencyscaling() {
|
||||
int fd;
|
||||
|
||||
fd = open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors", O_RDONLY);
|
||||
|
||||
if (-1==fd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
(void) close(fd);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int read_string(char* filename, char* buf, size_t buflen) {
|
||||
int fd;
|
||||
ssize_t r=-1;
|
||||
|
||||
memset (buf, 0, buflen);
|
||||
|
||||
fd = open (filename, O_RDONLY);
|
||||
if (-1<fd) {
|
||||
r = read (fd, buf, buflen-1);
|
||||
(void) close(fd);
|
||||
|
||||
if (-1==r) {
|
||||
fprintf(stderr, "Error while reading \"%s\": %s\n", filename, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
return (int) r;
|
||||
}
|
||||
|
||||
|
||||
static int read_int(char* filename, int* value) {
|
||||
char buf[20];
|
||||
|
||||
if (0<read_string(filename, buf, 20)) {
|
||||
return (1==sscanf(buf, "%d", value));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function determines wether any CPU core uses a variable clock speed if frequency
|
||||
* scaling is available. If the governor for all cores is either "powersave" or
|
||||
* "performance", the CPU frequency can be assumed to be static. This is also the case
|
||||
* if scaling_min_freq and scaling_max_freq are set to the same value.
|
||||
*
|
||||
* @returns 0 if system doesn't use frequency scaling at the moment, non-0 otherwise
|
||||
**/
|
||||
int system_uses_frequencyscaling() {
|
||||
int cpu=0, done=0, min, max;
|
||||
char filename[256], buf[256];
|
||||
|
||||
while (!done) {
|
||||
(void) snprintf(filename, 256, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor", cpu);
|
||||
if (0<read_string(filename, buf, 256)) {
|
||||
if ((0!=strcmp("performance", buf)) &&
|
||||
(0!=strcmp("powersafe", buf))) {
|
||||
// So it's neither the "performance" nor the "powersafe" governor
|
||||
(void) snprintf(filename, 256, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_min_freq", cpu);
|
||||
if (read_int(filename, &min)) {
|
||||
(void) snprintf(filename, 256, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq", cpu);
|
||||
if (read_int(filename, &max)) {
|
||||
if (min!=max) {
|
||||
// wrong governor AND different frequency limits -> scaling
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// couldn't open file -> no more cores
|
||||
done = 1;
|
||||
}
|
||||
cpu++;
|
||||
}
|
||||
|
||||
// couldn't find anything that points to scaling
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static gid_t get_group_by_name(const char* name) {
|
||||
struct group* grp;
|
||||
gid_t res = 0;
|
||||
|
||||
while ((0==res) && (NULL != (grp = getgrent()))) {
|
||||
if (0==strcmp(name, grp->gr_name)) {
|
||||
res = grp->gr_gid;
|
||||
}
|
||||
}
|
||||
|
||||
endgrent();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests wether the owner of this process is in the group 'name'.
|
||||
*
|
||||
* @returns 0 if the owner of this process is not in the group, non-0 otherwise
|
||||
**/
|
||||
int system_user_in_group(const char *name) {
|
||||
gid_t* list = (gid_t*) malloc(MAX_GROUPS * sizeof(gid_t));
|
||||
int num_groups, i=0, found=0;
|
||||
unsigned int gid;
|
||||
|
||||
if (NULL==list) {
|
||||
perror("Cannot allocate group list structure");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
gid = get_group_by_name(name);
|
||||
if (0==gid) {
|
||||
fprintf(stderr, "No %s group found\n", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
num_groups = getgroups(MAX_GROUPS, list);
|
||||
|
||||
while (i<num_groups) {
|
||||
if (list[i]==gid) {
|
||||
found = 1;
|
||||
i = num_groups;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
free(list);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* Checks for a definition in /etc/security/limits.conf that looks
|
||||
* as if it allows RT scheduling priority.
|
||||
*
|
||||
* @returns 1 if there appears to be such a line
|
||||
**/
|
||||
int system_has_rtprio_limits_conf ()
|
||||
{
|
||||
const char* limits = "/etc/security/limits.conf";
|
||||
char cmd[100];
|
||||
|
||||
snprintf (cmd, sizeof (cmd), "grep -q 'rtprio *[0-9][0-9]*' %s", limits);
|
||||
if (system (cmd) == 0) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks for the existence of the 'audio' group on this system
|
||||
*
|
||||
* @returns 0 if there is no 'audio' group, the group id otherwise
|
||||
**/
|
||||
int system_has_audiogroup() {
|
||||
return get_group_by_name("audio") || get_group_by_name ("jackuser");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks for the existence of 'groupname' on this system
|
||||
*
|
||||
* @returns 0 if there is no group, the group id otherwise
|
||||
**/
|
||||
int system_has_group(const char * name) {
|
||||
return get_group_by_name(name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests wether the owner of this process is in the 'audio' group.
|
||||
*
|
||||
* @returns 0 if the owner of this process is not in the audio group, non-0 otherwise
|
||||
**/
|
||||
int system_user_in_audiogroup() {
|
||||
return system_user_in_group("audio") || system_user_in_group("jackuser");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines wether the owner of this process can enable rt priority.
|
||||
*
|
||||
* @returns 0 if this process can not be switched to rt prio, non-0 otherwise
|
||||
**/
|
||||
int system_user_can_rtprio() {
|
||||
int min_prio;
|
||||
struct sched_param schparam;
|
||||
|
||||
memset(&schparam, 0, sizeof(struct sched_param));
|
||||
|
||||
if (-1 == (min_prio = sched_get_priority_min(SCHED_RR))) {
|
||||
perror("sched_get_priority");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
schparam.sched_priority = min_prio;
|
||||
|
||||
if (0 == sched_setscheduler(0, SCHED_RR, &schparam)) {
|
||||
// TODO: restore previous state
|
||||
schparam.sched_priority = 0;
|
||||
if (0 != sched_setscheduler(0, SCHED_OTHER, &schparam)) {
|
||||
perror("sched_setscheduler");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
long long unsigned int system_memlock_amount() {
|
||||
struct rlimit limits;
|
||||
|
||||
if (-1==getrlimit(RLIMIT_MEMLOCK, &limits)) {
|
||||
perror("getrlimit on RLIMIT_MEMLOCK");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return limits.rlim_max;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks wether the memlock limit is unlimited
|
||||
*
|
||||
* @returns - 0 if the memlock limit is limited, non-0 otherwise
|
||||
**/
|
||||
int system_memlock_is_unlimited() {
|
||||
return ((RLIM_INFINITY==system_memlock_amount())?1:0);
|
||||
}
|
||||
|
||||
|
||||
long long unsigned int system_available_physical_mem() {
|
||||
char buf[256];
|
||||
long long unsigned int res = 0;
|
||||
|
||||
if (0<read_string((char*)"/proc/meminfo", buf, sizeof (buf))) {
|
||||
if (strncmp (buf, "MemTotal:", 9) == 0) {
|
||||
if (sscanf (buf, "%*s %llu", &res) != 1) {
|
||||
perror ("parse error in /proc/meminfo");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
perror("read from /proc/meminfo");
|
||||
}
|
||||
|
||||
return res*1024;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the version of the currently running kernel. The string
|
||||
* returned has to be freed by the caller.
|
||||
*
|
||||
* @returns String with the full version of the kernel
|
||||
**/
|
||||
char* system_kernel_version() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char* system_get_username() {
|
||||
char* res = NULL;
|
||||
char* name = NULL;
|
||||
|
||||
if ((name = getlogin())) {
|
||||
res = strdup(name);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
109
tools/sanity_check/systemtest.h
Normal file
109
tools/sanity_check/systemtest.h
Normal file
@ -0,0 +1,109 @@
|
||||
#ifndef __systemtest_h__
|
||||
#define __systemtest_h__
|
||||
|
||||
/**
|
||||
* GPL, yabbadabba
|
||||
*
|
||||
* Set of functions to gather system information for the jack setup wizard.
|
||||
*
|
||||
* @author Florian Faber, faber@faberman.de
|
||||
*
|
||||
* @version 0.1 (2009-01-15) [FF]
|
||||
* - initial version
|
||||
*
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* This function checks for the existence of known frequency scaling mechanisms
|
||||
* in this system.
|
||||
*
|
||||
* @returns 0 if the system has no frequency scaling capabilities non-0 otherwise.
|
||||
**/
|
||||
int system_has_frequencyscaling();
|
||||
|
||||
|
||||
/**
|
||||
* This function determines wether the CPU has a variable clock speed if frequency
|
||||
* scaling is available.
|
||||
*
|
||||
* @returns 0 if system doesn't use frequency scaling at the moment, non-0 otherwise
|
||||
**/
|
||||
int system_uses_frequencyscaling();
|
||||
|
||||
/**
|
||||
* Tests wether the owner of this process is in the group 'name'.
|
||||
*
|
||||
* @returns 0 if the owner of this process is not in the group, non-0 otherwise
|
||||
**/
|
||||
int system_user_in_group(const char *name);
|
||||
|
||||
/***
|
||||
* Checks for a definition in /etc/security/limits.conf that looks
|
||||
* as if it allows RT scheduling priority.
|
||||
*
|
||||
* @returns 1 if there appears to be such a line
|
||||
**/
|
||||
int system_has_rtprio_limits_conf ();
|
||||
|
||||
/**
|
||||
* Checks for the existence of the 'audio' group on this system
|
||||
*
|
||||
* @returns 0 is there is no 'audio' group, non-0 otherwise
|
||||
**/
|
||||
int system_has_audiogroup();
|
||||
|
||||
/**
|
||||
* Checks for the existence of a group named 'name' on this system
|
||||
*
|
||||
* @returns 0 if not found, non-0 otherwise
|
||||
**/
|
||||
int system_has_group(const char * name);
|
||||
|
||||
/**
|
||||
* Tests wether the owner of this process is in the 'audio' group.
|
||||
*
|
||||
* @returns 0 if the owner of this process is not in the audio group, non-0 otherwise
|
||||
**/
|
||||
int system_user_in_audiogroup();
|
||||
|
||||
|
||||
/**
|
||||
* Determines wether the owner of this process can enable rt priority.
|
||||
*
|
||||
* @returns 0 if this process can not be switched to rt prio, non-0 otherwise
|
||||
**/
|
||||
int system_user_can_rtprio();
|
||||
|
||||
|
||||
long long unsigned int system_memlock_amount();
|
||||
|
||||
|
||||
/**
|
||||
* Checks wether the memlock limit is unlimited
|
||||
*
|
||||
* @returns 0 if the memlock limit is limited, non-0 otherwise
|
||||
**/
|
||||
int system_memlock_is_unlimited();
|
||||
|
||||
|
||||
long long unsigned int system_available_physical_mem();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the version of the currently running kernel
|
||||
*
|
||||
* @returns String with the full version of the kernel
|
||||
**/
|
||||
char* system_kernel_version();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the username. The caller is in charge of disposal of
|
||||
* the returned name.
|
||||
*
|
||||
* @returns Pointer to a username or NULL
|
||||
**/
|
||||
char* system_get_username();
|
||||
|
||||
#endif /* __jack_systemtest_h__ */
|
24
tools/sanity_check/wscript
Normal file
24
tools/sanity_check/wscript
Normal file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python
|
||||
import autowaf
|
||||
import Options
|
||||
import os
|
||||
|
||||
# Mandatory variables
|
||||
srcdir = '.'
|
||||
blddir = 'build'
|
||||
|
||||
def set_options(opt):
|
||||
autowaf.set_options(opt)
|
||||
|
||||
def configure(conf):
|
||||
autowaf.configure (conf)
|
||||
conf.check_tool('compiler_cxx')
|
||||
|
||||
def build(bld):
|
||||
obj = bld.new_task_gen(features = 'cxx cprogram')
|
||||
obj.includes = [ '.' ]
|
||||
obj.source = [ 'main.cpp', 'systemtest.cpp' ]
|
||||
obj.target = 'sanityCheck'
|
||||
obj.name = 'sanityCheck'
|
||||
obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
|
||||
|
Loading…
Reference in New Issue
Block a user