char *sccsid(void) { return (SCCSID); }
#endif
+#ifdef TEST
+extern int __env;
+#endif
+
struct stats_cpu *st_cpu[2];
unsigned long long uptime_cs[2] = {0, 0};
unsigned long long tot_jiffies[2] = {0, 0};
init_nls();
#endif
- /* Init color strings */
- init_colors();
-
/* Process args... */
while (opt < argc) {
opt++;
}
+#ifdef TEST
+ else if (!strncmp(argv[opt], "--getenv", 8)) {
+ __env = TRUE;
+ opt++;
+ }
+#endif
+
else if (!strncmp(argv[opt], "--dec=", 6) && (strlen(argv[opt]) == 7)) {
/* Get number of decimal places */
dplaces_nr = atoi(argv[opt] + 6);
count = 1;
}
+ /* Init color strings */
+ init_colors();
+
/* Default: Display CPU and DISK reports */
if (!report_set) {
flags |= I_D_CPU + I_D_DISK;
datafile[MAX_FILE_LEN - 1] = '\0';
default_file_used = TRUE;
+#ifdef DEBUG
+ fprintf(stderr, "%s: Datafile: %s\n", __FUNCTION__, datafile);
+#endif
+
return ((err < 0) || (err >= MAX_FILE_LEN));
}
#ifdef TEST
extern time_t __unix_time;
+extern int __env;
#endif
extern char *tzname[2];
}
#ifdef TEST
+ else if (!strncmp(argv[opt], "--getenv", 8)) {
+ __env = TRUE;
+ }
+
else if (!strncmp(argv[opt], "--unix_time=", 12)) {
if (strspn(argv[opt] + 12, DIGITS) != strlen(argv[opt] + 12)) {
usage(argv[0]);
#endif
#ifdef TEST
+extern int __env;
void int_handler(int n) { return; }
#endif
}
}
+#ifdef TEST
+ else if (!strncmp(argv[opt], "--getenv", 8)) {
+ __env = TRUE;
+ opt++;
+ }
+#endif
+
else if (!strcmp(argv[opt], "-O")) {
/* Parse output options */
if (!argv[++opt] || sar_options) {
#ifdef TEST
extern time_t __unix_time;
+extern int __env;
#endif
/* Interval and count parameters */
init_nls();
#endif
- /* Init color strings */
- init_colors();
-
tm_start.use = tm_end.use = FALSE;
/* Allocate and init activity bitmaps */
}
#ifdef TEST
+ else if (!strncmp(argv[opt], "--getenv", 8)) {
+ __env = TRUE;
+ opt++;
+ }
+
else if (!strncmp(argv[opt], "--unix_time=", 12)) {
if (strspn(argv[opt] + 12, DIGITS) != strlen(argv[opt] + 12)) {
usage(argv[0]);
}
}
+ /* Init color strings */
+ init_colors();
+
/* 'sar' is equivalent to 'sar -f' */
if ((argc == 1) ||
(((interval < 0) || INTERVAL_SET(flags)) && !from_file[0] && !to_file[0])) {
#include "systest.h"
time_t __unix_time = 0;
+int __env = 0;
+
extern long interval;
extern int sigint_caught;
* Test mode: Ignore environment variable value.
***************************************************************************
*/
-char *get_env_value(char *c)
+char *get_env_value(const char *c)
{
- return NULL;
+ if (!__env)
+ return NULL;
+
+ fprintf(stderr, "Reading contents of %s\n", c);
+ return getenv(c);
}
/*
void close_list
(DIR *);
char *get_env_value
- (char *);
+ (const char *);
int get_fs_stat
(char *, struct statvfs *);
char *get_realname