xref: /spdk/.githooks/pre-push (revision 6f338d4bf3a8a91b7abe377a605a321ea2b05bf7)
1#!/bin/sh
2# Verify what is about to be pushed.  Called by "git
3# push" after it has checked the remote status, but before anything has been
4# pushed.  If this script exits with a non-zero status nothing will be pushed.
5#
6# This hook is called with the following parameters:
7#
8# $1 -- Name of the remote to which the push is being done
9# $2 -- URL to which the push is being done
10#
11# If pushing without using a named remote those arguments will be equal.
12
13#   <local ref> <local sha1> <remote ref> <remote sha1>
14#
15
16rc=0
17SYSTEM=`uname -s`
18
19# Redirect output to stderr.
20exec 1>&2
21
22if [ "$SYSTEM" = "FreeBSD" ]; then
23	MAKE="gmake MAKE=gmake -j $(sysctl -a | grep -E -i 'hw.ncpu' | awk '{print $2}')"
24	COMP="clang"
25else
26	MAKE="make -j $(nproc)"
27	COMP="gcc"
28fi
29
30echo "Running make with $COMP ..."
31echo "${MAKE} clean " > make.log
32$MAKE clean  >> make.log 2>&1
33
34echo "${MAKE} CONFIG_DEBUG=n CONFIG_WERROR=y " >> make.log
35$MAKE CONFIG_DEBUG=n CONFIG_WERROR=y  >> make.log 2>&1
36rc=$?
37if [ $rc -ne 0 ]; then
38	tail -20 make.log
39	echo ""
40	echo "ERROR make returned errors!"
41	echo "ERROR Fix the problem and use 'git commit' to update your changes."
42	echo "ERROR See `pwd`/make.log for more information."
43	echo ""
44	exit $rc
45fi
46
47echo "${MAKE} SKIP_DPDK_BUILD=1 clean " >> make.log
48$MAKE clean SKIP_DPDK_BUILD=1 >> make.log 2>&1
49echo "${MAKE} CONFIG_DEBUG=y CONFIG_WERROR=y SKIP_DPDK_BUILD=1 " >> make.log
50$MAKE CONFIG_DEBUG=y CONFIG_WERROR=y SKIP_DPDK_BUILD=1  >> make.log 2>&1
51rc=$?
52if [ $rc -ne 0 ]; then
53	tail -20 make.log
54	echo ""
55	echo "ERROR make returned errors!"
56	echo "ERROR Fix the problem and use 'git commit' to update your changes."
57	echo "ERROR See `pwd`/make.log for more information."
58	echo ""
59	exit $rc
60fi
61
62echo "Running unittest.sh ..."
63echo "./test/unit/unittest.sh" >> make.log
64"./test/unit/unittest.sh" >> make.log 2>&1
65rc=$?
66if [ $rc -ne 0 ]; then
67	tail -20 make.log
68	echo ""
69	echo "ERROR unittest returned errors!"
70	echo "ERROR Fix the problem and use 'git commit' to update your changes."
71	echo "ERROR See `pwd`/make.log for more information."
72	echo ""
73	exit $rc
74fi
75
76echo "$MAKE clean " >> make.log
77$MAKE clean  >> make.log 2>&1
78
79echo "Pushing to $1 $2"
80
81exit $rc
82