Cyril Hrubis | 699238a | 2017-01-12 13:58:18 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz> |
| 3 | * |
| 4 | * This program is free software: you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation, either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #include <sys/utsname.h> |
| 19 | #include "test.h" |
| 20 | #include "tst_kernel.h" |
| 21 | |
| 22 | int tst_kernel_bits(void) |
| 23 | { |
| 24 | struct utsname buf; |
| 25 | int kernel_bits; |
| 26 | |
Cyril Hrubis | d101cab | 2017-02-14 11:48:46 +0100 | [diff] [blame] | 27 | if (uname(&buf)) { |
Cyril Hrubis | 699238a | 2017-01-12 13:58:18 +0100 | [diff] [blame] | 28 | tst_brkm(TBROK | TERRNO, NULL, "uname()"); |
Cyril Hrubis | d101cab | 2017-02-14 11:48:46 +0100 | [diff] [blame] | 29 | return -1; |
| 30 | } |
Cyril Hrubis | 699238a | 2017-01-12 13:58:18 +0100 | [diff] [blame] | 31 | |
| 32 | kernel_bits = strstr(buf.machine, "64") ? 64 : 32; |
| 33 | |
| 34 | tst_resm(TINFO, "uname.machine=%s kernel is %ibit", |
| 35 | buf.machine, kernel_bits); |
| 36 | |
| 37 | return kernel_bits; |
| 38 | } |