mirror of
https://github.com/microsoft/WSL.git
synced 2025-07-03 15:23:22 +00:00

Many Microsoft employees have contributed to the Windows Subsystem for Linux, this commit is the result of their work since 2016. The entire history of the Windows Subsystem for Linux can't be shared here, but here's an overview of WSL's history after it moved to it own repository in 2021: Number of commits on the main branch: 2930 Number of contributors: 31 Head over https://github.com/microsoft/WSL/releases for a more detailed history of the features added to WSL since 2021.
113 lines
2.8 KiB
C
113 lines
2.8 KiB
C
/*++
|
|
|
|
Copyright (c) Microsoft. All rights reserved.
|
|
|
|
Module Name:
|
|
|
|
Sysinfo.c
|
|
|
|
Abstract:
|
|
|
|
This file is a sysinfo test.
|
|
|
|
--*/
|
|
|
|
#include "lxtcommon.h"
|
|
#include "unittests.h"
|
|
#include "linux/kernel.h"
|
|
|
|
#define LXT_NAME "Sysinfo"
|
|
|
|
extern int sysinfo(struct sysinfo* info);
|
|
|
|
int SysinfoVariationPrint(PLXT_ARGS Args);
|
|
|
|
//
|
|
// Global constants
|
|
//
|
|
|
|
static const LXT_VARIATION g_LxtVariations[] = {{"SysinfoVariationPrint", SysinfoVariationPrint}};
|
|
|
|
int SysInfoTestEntry(int Argc, char* Argv[])
|
|
|
|
/*++
|
|
--*/
|
|
|
|
{
|
|
|
|
LXT_ARGS Args;
|
|
int Result;
|
|
|
|
LxtInitialize(Argc, Argv, &Args, LXT_NAME);
|
|
LxtCheckResult(LxtRunVariations(&Args, g_LxtVariations, LXT_COUNT_OF(g_LxtVariations)));
|
|
|
|
ErrorExit:
|
|
LxtUninitialize();
|
|
return !LXT_SUCCESS(Result);
|
|
}
|
|
|
|
int SysinfoVariationPrint(PLXT_ARGS Args)
|
|
|
|
/*++
|
|
--*/
|
|
|
|
{
|
|
|
|
int Result;
|
|
struct sysinfo SysInfo;
|
|
|
|
LxtCheckErrnoFailure(sysinfo(NULL), EFAULT);
|
|
LxtCheckErrno(sysinfo(&SysInfo));
|
|
LxtLogInfo(
|
|
"SysInfo.uptime: %d\n"
|
|
"SysInfo.loads[0]: %d\n"
|
|
"SysInfo.loads[1]: %d\n"
|
|
"SysInfo.loads[2]: %d\n"
|
|
"SysInfo.totalram: %d\n"
|
|
"SysInfo.freeram: %d\n"
|
|
"SysInfo.sharedram: %d\n"
|
|
"SysInfo.bufferram: %d\n"
|
|
"SysInfo.totalswap: %d\n"
|
|
"SysInfo.freeswap: %d\n"
|
|
"SysInfo.procs: %d\n"
|
|
"SysInfo.pad: %d\n"
|
|
"SysInfo.totalhigh: %d\n"
|
|
"SysInfo.freehigh: %d\n"
|
|
"SysInfo.mem_unit: %d\n",
|
|
SysInfo.uptime,
|
|
SysInfo.loads[0],
|
|
SysInfo.loads[1],
|
|
SysInfo.loads[2],
|
|
SysInfo.totalram,
|
|
SysInfo.freeram,
|
|
SysInfo.sharedram,
|
|
SysInfo.bufferram,
|
|
SysInfo.totalswap,
|
|
SysInfo.freeswap,
|
|
SysInfo.procs,
|
|
SysInfo.pad,
|
|
SysInfo.totalhigh,
|
|
SysInfo.freehigh,
|
|
SysInfo.mem_unit);
|
|
|
|
LxtCheckGreater(SysInfo.uptime, 0, "%d");
|
|
LxtCheckEqual(SysInfo.loads[0], 33984, "%d");
|
|
LxtCheckEqual(SysInfo.loads[1], 37856, "%d");
|
|
LxtCheckEqual(SysInfo.loads[2], 38400, "%d");
|
|
LxtCheckGreater(SysInfo.totalram, 0, "%d");
|
|
LxtCheckGreater(SysInfo.freeram, 0, "%d");
|
|
LxtCheckEqual(SysInfo.sharedram, 0, "%d");
|
|
LxtCheckEqual(SysInfo.bufferram, 0, "%d");
|
|
LxtCheckGreater(SysInfo.totalswap, 0, "%d");
|
|
LxtCheckGreater(SysInfo.freeswap, 0, "%d");
|
|
LxtCheckGreater(SysInfo.procs, 1, "%d"); // TODO: change back to 2, right now there is only a single process running.
|
|
LxtCheckEqual(SysInfo.pad, 0, "%d");
|
|
LxtCheckEqual(SysInfo.totalhigh, 139208 * 1024, "%d");
|
|
LxtCheckEqual(SysInfo.freehigh, 272 * 1024, "%d");
|
|
LxtCheckEqual(SysInfo.mem_unit, 1, "%d");
|
|
|
|
Result = LXT_RESULT_SUCCESS;
|
|
|
|
ErrorExit:
|
|
return Result;
|
|
}
|