aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/include/tools/be_byteshift.h70
-rw-r--r--tools/include/tools/le_byteshift.h70
-rw-r--r--tools/perf/util/include/linux/bitops.h2
-rwxr-xr-xtools/testing/ktest/ktest.pl56
-rw-r--r--tools/testing/ktest/sample.conf14
-rw-r--r--tools/usb/Makefile2
-rw-r--r--tools/usb/ffs-test.c29
7 files changed, 199 insertions, 44 deletions
diff --git a/tools/include/tools/be_byteshift.h b/tools/include/tools/be_byteshift.h
new file mode 100644
index 000000000000..f4912e2668ba
--- /dev/null
+++ b/tools/include/tools/be_byteshift.h
@@ -0,0 +1,70 @@
1#ifndef _TOOLS_BE_BYTESHIFT_H
2#define _TOOLS_BE_BYTESHIFT_H
3
4#include <linux/types.h>
5
6static inline __u16 __get_unaligned_be16(const __u8 *p)
7{
8 return p[0] << 8 | p[1];
9}
10
11static inline __u32 __get_unaligned_be32(const __u8 *p)
12{
13 return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
14}
15
16static inline __u64 __get_unaligned_be64(const __u8 *p)
17{
18 return (__u64)__get_unaligned_be32(p) << 32 |
19 __get_unaligned_be32(p + 4);
20}
21
22static inline void __put_unaligned_be16(__u16 val, __u8 *p)
23{
24 *p++ = val >> 8;
25 *p++ = val;
26}
27
28static inline void __put_unaligned_be32(__u32 val, __u8 *p)
29{
30 __put_unaligned_be16(val >> 16, p);
31 __put_unaligned_be16(val, p + 2);
32}
33
34static inline void __put_unaligned_be64(__u64 val, __u8 *p)
35{
36 __put_unaligned_be32(val >> 32, p);
37 __put_unaligned_be32(val, p + 4);
38}
39
40static inline __u16 get_unaligned_be16(const void *p)
41{
42 return __get_unaligned_be16((const __u8 *)p);
43}
44
45static inline __u32 get_unaligned_be32(const void *p)
46{
47 return __get_unaligned_be32((const __u8 *)p);
48}
49
50static inline __u64 get_unaligned_be64(const void *p)
51{
52 return __get_unaligned_be64((const __u8 *)p);
53}
54
55static inline void put_unaligned_be16(__u16 val, void *p)
56{
57 __put_unaligned_be16(val, p);
58}
59
60static inline void put_unaligned_be32(__u32 val, void *p)
61{
62 __put_unaligned_be32(val, p);
63}
64
65static inline void put_unaligned_be64(__u64 val, void *p)
66{
67 __put_unaligned_be64(val, p);
68}
69
70#endif /* _TOOLS_BE_BYTESHIFT_H */
diff --git a/tools/include/tools/le_byteshift.h b/tools/include/tools/le_byteshift.h
new file mode 100644
index 000000000000..c99d45a68bda
--- /dev/null
+++ b/tools/include/tools/le_byteshift.h
@@ -0,0 +1,70 @@
1#ifndef _TOOLS_LE_BYTESHIFT_H
2#define _TOOLS_LE_BYTESHIFT_H
3
4#include <linux/types.h>
5
6static inline __u16 __get_unaligned_le16(const __u8 *p)
7{
8 return p[0] | p[1] << 8;
9}
10
11static inline __u32 __get_unaligned_le32(const __u8 *p)
12{
13 return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
14}
15
16static inline __u64 __get_unaligned_le64(const __u8 *p)
17{
18 return (__u64)__get_unaligned_le32(p + 4) << 32 |
19 __get_unaligned_le32(p);
20}
21
22static inline void __put_unaligned_le16(__u16 val, __u8 *p)
23{
24 *p++ = val;
25 *p++ = val >> 8;
26}
27
28static inline void __put_unaligned_le32(__u32 val, __u8 *p)
29{
30 __put_unaligned_le16(val >> 16, p + 2);
31 __put_unaligned_le16(val, p);
32}
33
34static inline void __put_unaligned_le64(__u64 val, __u8 *p)
35{
36 __put_unaligned_le32(val >> 32, p + 4);
37 __put_unaligned_le32(val, p);
38}
39
40static inline __u16 get_unaligned_le16(const void *p)
41{
42 return __get_unaligned_le16((const __u8 *)p);
43}
44
45static inline __u32 get_unaligned_le32(const void *p)
46{
47 return __get_unaligned_le32((const __u8 *)p);
48}
49
50static inline __u64 get_unaligned_le64(const void *p)
51{
52 return __get_unaligned_le64((const __u8 *)p);
53}
54
55static inline void put_unaligned_le16(__u16 val, void *p)
56{
57 __put_unaligned_le16(val, p);
58}
59
60static inline void put_unaligned_le32(__u32 val, void *p)
61{
62 __put_unaligned_le32(val, p);
63}
64
65static inline void put_unaligned_le64(__u64 val, void *p)
66{
67 __put_unaligned_le64(val, p);
68}
69
70#endif /* _TOOLS_LE_BYTESHIFT_H */
diff --git a/tools/perf/util/include/linux/bitops.h b/tools/perf/util/include/linux/bitops.h
index 62cdee78db7b..f1584833bd22 100644
--- a/tools/perf/util/include/linux/bitops.h
+++ b/tools/perf/util/include/linux/bitops.h
@@ -15,7 +15,7 @@
15 (bit) = find_next_bit((addr), (size), (bit) + 1)) 15 (bit) = find_next_bit((addr), (size), (bit) + 1))
16 16
17/* same as for_each_set_bit() but use bit as value to start with */ 17/* same as for_each_set_bit() but use bit as value to start with */
18#define for_each_set_bit_cont(bit, addr, size) \ 18#define for_each_set_bit_from(bit, addr, size) \
19 for ((bit) = find_next_bit((addr), (size), (bit)); \ 19 for ((bit) = find_next_bit((addr), (size), (bit)); \
20 (bit) < (size); \ 20 (bit) < (size); \
21 (bit) = find_next_bit((addr), (size), (bit) + 1)) 21 (bit) = find_next_bit((addr), (size), (bit) + 1))
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 758ec2a08c40..95d6a6f7c33a 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -46,6 +46,7 @@ my %default = (
46 "DIE_ON_FAILURE" => 1, 46 "DIE_ON_FAILURE" => 1,
47 "SSH_EXEC" => "ssh \$SSH_USER\@\$MACHINE \$SSH_COMMAND", 47 "SSH_EXEC" => "ssh \$SSH_USER\@\$MACHINE \$SSH_COMMAND",
48 "SCP_TO_TARGET" => "scp \$SRC_FILE \$SSH_USER\@\$MACHINE:\$DST_FILE", 48 "SCP_TO_TARGET" => "scp \$SRC_FILE \$SSH_USER\@\$MACHINE:\$DST_FILE",
49 "SCP_TO_TARGET_INSTALL" => "\${SCP_TO_TARGET}",
49 "REBOOT" => "ssh \$SSH_USER\@\$MACHINE reboot", 50 "REBOOT" => "ssh \$SSH_USER\@\$MACHINE reboot",
50 "STOP_AFTER_SUCCESS" => 10, 51 "STOP_AFTER_SUCCESS" => 10,
51 "STOP_AFTER_FAILURE" => 60, 52 "STOP_AFTER_FAILURE" => 60,
@@ -86,11 +87,13 @@ my $reboot_on_error;
86my $switch_to_good; 87my $switch_to_good;
87my $switch_to_test; 88my $switch_to_test;
88my $poweroff_on_error; 89my $poweroff_on_error;
90my $reboot_on_success;
89my $die_on_failure; 91my $die_on_failure;
90my $powercycle_after_reboot; 92my $powercycle_after_reboot;
91my $poweroff_after_halt; 93my $poweroff_after_halt;
92my $ssh_exec; 94my $ssh_exec;
93my $scp_to_target; 95my $scp_to_target;
96my $scp_to_target_install;
94my $power_off; 97my $power_off;
95my $grub_menu; 98my $grub_menu;
96my $grub_number; 99my $grub_number;
@@ -211,6 +214,7 @@ my %option_map = (
211 "SWITCH_TO_GOOD" => \$switch_to_good, 214 "SWITCH_TO_GOOD" => \$switch_to_good,
212 "SWITCH_TO_TEST" => \$switch_to_test, 215 "SWITCH_TO_TEST" => \$switch_to_test,
213 "POWEROFF_ON_ERROR" => \$poweroff_on_error, 216 "POWEROFF_ON_ERROR" => \$poweroff_on_error,
217 "REBOOT_ON_SUCCESS" => \$reboot_on_success,
214 "DIE_ON_FAILURE" => \$die_on_failure, 218 "DIE_ON_FAILURE" => \$die_on_failure,
215 "POWER_OFF" => \$power_off, 219 "POWER_OFF" => \$power_off,
216 "POWERCYCLE_AFTER_REBOOT" => \$powercycle_after_reboot, 220 "POWERCYCLE_AFTER_REBOOT" => \$powercycle_after_reboot,
@@ -243,6 +247,7 @@ my %option_map = (
243 "BUILD_TARGET" => \$build_target, 247 "BUILD_TARGET" => \$build_target,
244 "SSH_EXEC" => \$ssh_exec, 248 "SSH_EXEC" => \$ssh_exec,
245 "SCP_TO_TARGET" => \$scp_to_target, 249 "SCP_TO_TARGET" => \$scp_to_target,
250 "SCP_TO_TARGET_INSTALL" => \$scp_to_target_install,
246 "CHECKOUT" => \$checkout, 251 "CHECKOUT" => \$checkout,
247 "TARGET_IMAGE" => \$target_image, 252 "TARGET_IMAGE" => \$target_image,
248 "LOCALVERSION" => \$localversion, 253 "LOCALVERSION" => \$localversion,
@@ -1113,7 +1118,6 @@ sub reboot_to_good {
1113 1118
1114 if (defined($switch_to_good)) { 1119 if (defined($switch_to_good)) {
1115 run_command $switch_to_good; 1120 run_command $switch_to_good;
1116 return;
1117 } 1121 }
1118 1122
1119 reboot $time; 1123 reboot $time;
@@ -1349,8 +1353,7 @@ sub run_ssh {
1349} 1353}
1350 1354
1351sub run_scp { 1355sub run_scp {
1352 my ($src, $dst) = @_; 1356 my ($src, $dst, $cp_scp) = @_;
1353 my $cp_scp = $scp_to_target;
1354 1357
1355 $cp_scp =~ s/\$SRC_FILE/$src/g; 1358 $cp_scp =~ s/\$SRC_FILE/$src/g;
1356 $cp_scp =~ s/\$DST_FILE/$dst/g; 1359 $cp_scp =~ s/\$DST_FILE/$dst/g;
@@ -1358,6 +1361,22 @@ sub run_scp {
1358 return run_command "$cp_scp"; 1361 return run_command "$cp_scp";
1359} 1362}
1360 1363
1364sub run_scp_install {
1365 my ($src, $dst) = @_;
1366
1367 my $cp_scp = $scp_to_target_install;
1368
1369 return run_scp($src, $dst, $cp_scp);
1370}
1371
1372sub run_scp_mod {
1373 my ($src, $dst) = @_;
1374
1375 my $cp_scp = $scp_to_target;
1376
1377 return run_scp($src, $dst, $cp_scp);
1378}
1379
1361sub get_grub_index { 1380sub get_grub_index {
1362 1381
1363 if ($reboot_type ne "grub") { 1382 if ($reboot_type ne "grub") {
@@ -1460,6 +1479,7 @@ sub get_sha1 {
1460sub monitor { 1479sub monitor {
1461 my $booted = 0; 1480 my $booted = 0;
1462 my $bug = 0; 1481 my $bug = 0;
1482 my $bug_ignored = 0;
1463 my $skip_call_trace = 0; 1483 my $skip_call_trace = 0;
1464 my $loops; 1484 my $loops;
1465 1485
@@ -1531,9 +1551,13 @@ sub monitor {
1531 } 1551 }
1532 1552
1533 if ($full_line =~ /call trace:/i) { 1553 if ($full_line =~ /call trace:/i) {
1534 if (!$ignore_errors && !$bug && !$skip_call_trace) { 1554 if (!$bug && !$skip_call_trace) {
1535 $bug = 1; 1555 if ($ignore_errors) {
1536 $failure_start = time; 1556 $bug_ignored = 1;
1557 } else {
1558 $bug = 1;
1559 $failure_start = time;
1560 }
1537 } 1561 }
1538 } 1562 }
1539 1563
@@ -1595,6 +1619,10 @@ sub monitor {
1595 fail "failed - never got a boot prompt." and return 0; 1619 fail "failed - never got a boot prompt." and return 0;
1596 } 1620 }
1597 1621
1622 if ($bug_ignored) {
1623 doprint "WARNING: Call Trace detected but ignored due to IGNORE_ERRORS=1\n";
1624 }
1625
1598 return 1; 1626 return 1;
1599} 1627}
1600 1628
@@ -1621,7 +1649,7 @@ sub install {
1621 1649
1622 my $cp_target = eval_kernel_version $target_image; 1650 my $cp_target = eval_kernel_version $target_image;
1623 1651
1624 run_scp "$outputdir/$build_target", "$cp_target" or 1652 run_scp_install "$outputdir/$build_target", "$cp_target" or
1625 dodie "failed to copy image"; 1653 dodie "failed to copy image";
1626 1654
1627 my $install_mods = 0; 1655 my $install_mods = 0;
@@ -1643,7 +1671,7 @@ sub install {
1643 return; 1671 return;
1644 } 1672 }
1645 1673
1646 run_command "$make INSTALL_MOD_PATH=$tmpdir modules_install" or 1674 run_command "$make INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$tmpdir modules_install" or
1647 dodie "Failed to install modules"; 1675 dodie "Failed to install modules";
1648 1676
1649 my $modlib = "/lib/modules/$version"; 1677 my $modlib = "/lib/modules/$version";
@@ -1656,7 +1684,7 @@ sub install {
1656 run_command "cd $tmpdir && tar -cjf $modtar lib/modules/$version" or 1684 run_command "cd $tmpdir && tar -cjf $modtar lib/modules/$version" or
1657 dodie "making tarball"; 1685 dodie "making tarball";
1658 1686
1659 run_scp "$tmpdir/$modtar", "/tmp" or 1687 run_scp_mod "$tmpdir/$modtar", "/tmp" or
1660 dodie "failed to copy modules"; 1688 dodie "failed to copy modules";
1661 1689
1662 unlink "$tmpdir/$modtar"; 1690 unlink "$tmpdir/$modtar";
@@ -3526,8 +3554,10 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
3526 die "failed to checkout $checkout"; 3554 die "failed to checkout $checkout";
3527 } 3555 }
3528 3556
3529 $no_reboot = 0; 3557 # A test may opt to not reboot the box
3530 3558 if ($reboot_on_success) {
3559 $no_reboot = 0;
3560 }
3531 3561
3532 if ($test_type eq "bisect") { 3562 if ($test_type eq "bisect") {
3533 bisect $i; 3563 bisect $i;
@@ -3572,8 +3602,12 @@ if ($opt{"POWEROFF_ON_SUCCESS"}) {
3572 halt; 3602 halt;
3573} elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot) { 3603} elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot) {
3574 reboot_to_good; 3604 reboot_to_good;
3605} elsif (defined($switch_to_good)) {
3606 # still need to get to the good kernel
3607 run_command $switch_to_good;
3575} 3608}
3576 3609
3610
3577doprint "\n $successes of $opt{NUM_TESTS} tests were successful\n\n"; 3611doprint "\n $successes of $opt{NUM_TESTS} tests were successful\n\n";
3578 3612
3579exit 0; 3613exit 0;
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf
index 5ea04c6a71bf..b682456afda8 100644
--- a/tools/testing/ktest/sample.conf
+++ b/tools/testing/ktest/sample.conf
@@ -710,10 +710,18 @@
710# The variables SSH_USER, MACHINE and SSH_COMMAND are defined 710# The variables SSH_USER, MACHINE and SSH_COMMAND are defined
711#SSH_EXEC = ssh $SSH_USER@$MACHINE $SSH_COMMAND"; 711#SSH_EXEC = ssh $SSH_USER@$MACHINE $SSH_COMMAND";
712 712
713# The way to copy a file to the target 713# The way to copy a file to the target (install and modules)
714# (default scp $SRC_FILE $SSH_USER@$MACHINE:$DST_FILE) 714# (default scp $SRC_FILE $SSH_USER@$MACHINE:$DST_FILE)
715# The variables SSH_USER, MACHINE, SRC_FILE and DST_FILE are defined. 715# The variables SSH_USER, MACHINE are defined by the config
716#SCP_TO_TARGET = scp $SRC_FILE $SSH_USER@$MACHINE:$DST_FILE 716# SRC_FILE and DST_FILE are ktest internal variables and
717# should only have '$' and not the '${}' notation.
718# (default scp $SRC_FILE ${SSH_USER}@${MACHINE}:$DST_FILE)
719#SCP_TO_TARGET = echo skip scp for $SRC_FILE $DST_FILE
720
721# If install needs to be different than modules, then this
722# option will override the SCP_TO_TARGET for installation.
723# (default ${SCP_TO_TARGET} )
724#SCP_TO_TARGET_INSTALL = scp $SRC_FILE tftp@tftpserver:$DST_FILE
717 725
718# The nice way to reboot the target 726# The nice way to reboot the target
719# (default ssh $SSH_USER@$MACHINE reboot) 727# (default ssh $SSH_USER@$MACHINE reboot)
diff --git a/tools/usb/Makefile b/tools/usb/Makefile
index 8b704af14349..396d6c44e9d7 100644
--- a/tools/usb/Makefile
+++ b/tools/usb/Makefile
@@ -3,7 +3,7 @@
3CC = $(CROSS_COMPILE)gcc 3CC = $(CROSS_COMPILE)gcc
4PTHREAD_LIBS = -lpthread 4PTHREAD_LIBS = -lpthread
5WARNINGS = -Wall -Wextra 5WARNINGS = -Wall -Wextra
6CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS) 6CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS) -I../include
7 7
8all: testusb ffs-test 8all: testusb ffs-test
9%: %.c 9%: %.c
diff --git a/tools/usb/ffs-test.c b/tools/usb/ffs-test.c
index 53452c35d5e1..4b107b5e623f 100644
--- a/tools/usb/ffs-test.c
+++ b/tools/usb/ffs-test.c
@@ -36,6 +36,7 @@
36#include <sys/stat.h> 36#include <sys/stat.h>
37#include <sys/types.h> 37#include <sys/types.h>
38#include <unistd.h> 38#include <unistd.h>
39#include <tools/le_byteshift.h>
39 40
40#include "../../include/linux/usb/functionfs.h" 41#include "../../include/linux/usb/functionfs.h"
41 42
@@ -47,34 +48,6 @@
47#define le32_to_cpu(x) le32toh(x) 48#define le32_to_cpu(x) le32toh(x)
48#define le16_to_cpu(x) le16toh(x) 49#define le16_to_cpu(x) le16toh(x)
49 50
50static inline __u16 get_unaligned_le16(const void *_ptr)
51{
52 const __u8 *ptr = _ptr;
53 return ptr[0] | (ptr[1] << 8);
54}
55
56static inline __u32 get_unaligned_le32(const void *_ptr)
57{
58 const __u8 *ptr = _ptr;
59 return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24);
60}
61
62static inline void put_unaligned_le16(__u16 val, void *_ptr)
63{
64 __u8 *ptr = _ptr;
65 *ptr++ = val;
66 *ptr++ = val >> 8;
67}
68
69static inline void put_unaligned_le32(__u32 val, void *_ptr)
70{
71 __u8 *ptr = _ptr;
72 *ptr++ = val;
73 *ptr++ = val >> 8;
74 *ptr++ = val >> 16;
75 *ptr++ = val >> 24;
76}
77
78 51
79/******************** Messages and Errors ***********************************/ 52/******************** Messages and Errors ***********************************/
80 53