-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
samples: posix: add sample for uname
Add a simple sample to print everything in the utsname struct. Signed-off-by: Yong Cong Sin <ycsin@meta.com>
- Loading branch information
Showing
6 changed files
with
67 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(posix_uname) | ||
|
||
target_sources(app PRIVATE src/main.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CONFIG_POSIX_API=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
sample: | ||
description: posix uname sample | ||
name: posix uname | ||
common: | ||
tags: posix | ||
filter: not CONFIG_ARCH_POSIX | ||
integration_platforms: | ||
- native_posix_64 | ||
- qemu_riscv64 | ||
harness: console | ||
harness_config: | ||
type: multi_line | ||
ordered: true | ||
regex: | ||
- "sysname\\[7\\]: Zephyr" | ||
- "nodename\\[\\d+\\]: .*" | ||
- "release\\[\\d+\\]: \\d+\\.\\d+\\.\\d+" | ||
- "version\\[\\d+\\]: .*" | ||
- "machine\\[\\d+\\]: .*" | ||
tests: | ||
sample.posix.uname: | ||
tags: uname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) 2023 Meta | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <sys/utsname.h> | ||
|
||
int main(void) | ||
{ | ||
struct utsname info; | ||
|
||
uname(&info); | ||
|
||
printk("\nPrinting everything in utsname...\n"); | ||
printk("sysname[%ld]: %s\n", sizeof(info.sysname), info.sysname); | ||
printk("nodename[%ld]: %s\n", sizeof(info.nodename), info.nodename); | ||
printk("release[%ld]: %s\n", sizeof(info.release), info.release); | ||
printk("version[%ld]: %s\n", sizeof(info.version), info.version); | ||
printk("machine[%ld]: %s\n", sizeof(info.machine), info.machine); | ||
|
||
return 0; | ||
} | ||
|
||
|
||
return 0; | ||
} |