brintos

brintos / llvm-project-archived public Read only

0
0
Text · 822 B · acdfb17 Raw
45 lines · cpp
1// RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s2 3#include <sys/param.h>4#include <sys/types.h>5 6#include <sys/sysctl.h>7 8#include <assert.h>9#include <stdio.h>10#include <stdlib.h>11 12void test_asysctl() {13  int mib[] = {CTL_KERN, KERN_OSTYPE};14  size_t len;15  char *buf = (char *)asysctl(mib, __arraycount(mib), &len);16  assert(buf);17 18  printf("asysctl: '%s' size: '%zu'\n", buf, len);19 20  free(buf);21}22 23void test_asysctlbyname() {24  size_t len;25  char *buf = (char *)asysctlbyname("kern.ostype", &len);26  assert(buf);27 28  printf("asysctlbyname: '%s' size: '%zu'\n", buf, len);29 30  free(buf);31}32 33int main(void) {34  printf("asysctl\n");35 36  test_asysctl();37  test_asysctlbyname();38 39  return 0;40 41  // CHECK: asysctl42  // CHECK: asysctl: '{{.*}}' size: '{{.*}}'43  // CHECK: asysctlbyname: '{{.*}}' size: '{{.*}}'44}45