blob: 71303fc367bbe5e8902c447466924e5478a9eceb [file] [log] [blame]
Cyril Hrubis699238a2017-01-12 13:58:18 +01001/*
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
22int tst_kernel_bits(void)
23{
24 struct utsname buf;
25 int kernel_bits;
26
Cyril Hrubisd101cab2017-02-14 11:48:46 +010027 if (uname(&buf)) {
Cyril Hrubis699238a2017-01-12 13:58:18 +010028 tst_brkm(TBROK | TERRNO, NULL, "uname()");
Cyril Hrubisd101cab2017-02-14 11:48:46 +010029 return -1;
30 }
Cyril Hrubis699238a2017-01-12 13:58:18 +010031
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}