-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_aliases
438 lines (394 loc) · 13.9 KB
/
bash_aliases
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# .bash_aliases
# Allow for a local .bash_aliases
LOCAL_BASH_ALIASES=$HOME/.bash_aliases.local
if [ -f $LOCAL_BASH_ALIASES ]; then
source $LOCAL_BASH_ALIASES
fi
unset LOCAL_BASH_ALIASES
# emacs
alias e='emacs -nw'
alias f='cd ~/src/flume'
alias k='cd ~/src/kudu'
# Git shortcuts
update_func() {
BRANCH=$1
if [[ -z "$BRANCH" ]]; then
echo "Usage: update <branch>"
return 1
fi
(
set -x
git checkout $BRANCH
git pull --ff-only
)
}
alias update=update_func
# re-enable keyboard mappings
#alias xmm='xmodmap ~/.xmodmaprc'
export LLVM_SYMBOLIZER=/home/mpercy/src/kudu/thirdparty/clang-toolchain/bin/llvm-symbolizer
export DEVTOOLSET='../../build-support/enable_devtoolset.sh'
export CMAKE='../../thirdparty/installed/common/bin/cmake'
NUM_PROCS=$(getconf _NPROCESSORS_ONLN)
export NUM_PROCS_MINUS_ONE=$(expr $NUM_PROCS - 1)
export CMAKE_GENERATOR=${CMAKE_GENERATOR:-Ninja}
export CMAKE_MAKE_PROG=${CMAKE_MAKE_PROG:-ninja}
kudu_gerrit_submit_branch() {
(
local BRANCH=$1
shift
if [ -z "$BRANCH" ]; then
echo =======================================================
echo "ERROR: No branch specified."
echo =======================================================
return 1
fi
# TODO: figure out how to deal with dual thirdparty
#if ! git diff-index --quiet HEAD --; then
# echo ================================================================================
# echo "ERROR: Changes present in local tree. Please commit before pushing to Gerrit."
# echo ================================================================================
# echo
# git status --untracked-files=no
# return 1
#fi
local GERRIT_CMD="git push --no-thin gerrit HEAD:refs/for/$BRANCH"
local ARGS=""
while [ -n "$1" ]; do
local REVIEWER=$1
shift
if [ -z "$ARGS" ]; then
ARGS="%"
else
ARGS="${ARGS},"
fi
ARGS="${ARGS}r=$REVIEWER"
done
GERRIT_CMD="${GERRIT_CMD}${ARGS}"
set -xe
$GERRIT_CMD
)
}
kudu_gerrit_submit() {
kudu_gerrit_submit_branch master $*
}
kudu_gerrit_submit_current_branch() {
local BRANCH=$(git rev-parse --abbrev-ref HEAD)
kudu_gerrit_submit_branch "$BRANCH" $*
}
# kudu aliases
alias gerrit_submit=kudu_gerrit_submit
alias gerrit_submit_current_branch=kudu_gerrit_submit_current_branch
alias gerrit_submit_branch=kudu_gerrit_submit_branch
alias toolset-ninja='export CMAKE_GENERATOR=Ninja; export CMAKE_MAKE_PROG=ninja'
alias toolset-xcode='export CMAKE_GENERATOR=Xcode; export CMAKE_MAKE_PROG=xcodebuild'
kudu_run_cmake_func() {
(
set -x
BUILD_TYPE=$1
if [ -z "$BUILD_TYPE" ]; then
echo Error: Must specify build type
return
fi
if [ -z "$NO_REBUILD_THIRDPARTY" ]; then
$DEVTOOLSET ../../thirdparty/build-if-necessary.sh
fi
rm -Rf CMakeCache.txt CMakeFiles/
CMAKE_OPTS="-DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DKUDU_FORCE_COLOR_DIAGNOSTICS=1 $CMAKE_OPTS"
case $BUILD_TYPE in
DYNDEBUG)
$DEVTOOLSET $CMAKE ../.. -G $CMAKE_GENERATOR $CMAKE_OPTS -DCMAKE_BUILD_TYPE=debug
;;
DEBUG)
$DEVTOOLSET $CMAKE ../.. -G $CMAKE_GENERATOR $CMAKE_OPTS -DKUDU_LINK=static -DCMAKE_BUILD_TYPE=debug
;;
CLANGDEBUG)
CC=clang CXX=clang++ $DEVTOOLSET $CMAKE ../.. -G $CMAKE_GENERATOR $CMAKE_OPTS -DKUDU_LINK=static -DCMAKE_BUILD_TYPE=debug
;;
DYNCLANG)
# Probably the fastest build method.
CC=clang CXX=clang++ $DEVTOOLSET $CMAKE ../.. -G $CMAKE_GENERATOR $CMAKE_OPTS -DKUDU_LINK=dynamic -DCMAKE_BUILD_TYPE=debug
;;
ASAN)
CC=clang CXX=clang++ $DEVTOOLSET $CMAKE ../.. -G $CMAKE_GENERATOR $CMAKE_OPTS -DCMAKE_BUILD_TYPE=fastdebug -DKUDU_USE_ASAN=1
;;
ASANDEBUG)
CC=clang CXX=clang++ $DEVTOOLSET $CMAKE ../.. -G $CMAKE_GENERATOR $CMAKE_OPTS -DCMAKE_BUILD_TYPE=debug -DKUDU_USE_ASAN=1 -DKUDU_USE_UBSAN=1 -DKUDU_LINK=static
;;
TSAN)
CC=clang CXX=clang++ $DEVTOOLSET $CMAKE ../.. -G $CMAKE_GENERATOR $CMAKE_OPTS -DCMAKE_BUILD_TYPE=fastdebug -DKUDU_USE_TSAN=1
;;
TSANDEBUG)
CC=clang CXX=clang++ $DEVTOOLSET $CMAKE ../.. -G $CMAKE_GENERATOR $CMAKE_OPTS -DCMAKE_BUILD_TYPE=debug -DKUDU_USE_TSAN=1
;;
COVERAGE)
CC=clang CXX=clang++ $DEVTOOLSET $CMAKE ../.. -G $CMAKE_GENERATOR $CMAKE_OPTS -DKUDU_LINK=dynamic -DCMAKE_BUILD_TYPE=debug -DKUDU_GENERATE_COVERAGE=1
;;
CLIENT)
CC=clang CXX=clang++ $DEVTOOLSET $CMAKE ../.. -G $CMAKE_GENERATOR $CMAKE_OPTS -DCMAKE_BUILD_TYPE=debug -DKUDU_EXPORTED_CLIENT=1
;;
RELEASE|HEAPCHECK)
$DEVTOOLSET $CMAKE ../.. -G $CMAKE_GENERATOR $CMAKE_OPTS -DCMAKE_BUILD_TYPE=release
;;
esac
$DEVTOOLSET $CMAKE_MAKE_PROG clean
)
}
kudu_ensure_build_type() {
BUILD_TYPE=$1
CURRENT_BUILD_TYPE=$(grep CMAKE_BUILD_TYPE CMakeCache.txt | cut -d= -f2)
if [ "$BUILD_TYPE" != "$CURRENT_BUILD_TYPE" ]; then
kudu_run_cmake_func "$BUILD_TYPE"
fi
}
kudu_build_func() {
BUILD_TYPE=$1
date \
&&
kudu_run_cmake_func $BUILD_TYPE \
&& date \
&& time $DEVTOOLSET $CMAKE_MAKE_PROG -j${NUM_PROCS_MINUS_ONE} $NINJA_OPTS
}
kudu_make_and_test_func() {
BUILD_TYPE=$1
kudu_build_func $BUILD_TYPE \
&& rm -rf /tmp/kudutest-1000 \
&& date \
&& time ctest -j${NUM_PROCS_MINUS_ONE}
}
alias kudu_build='kudu_make_and_test_func DEBUG'
alias kudu_build_dyn='kudu_make_and_test_func DYNDEBUG'
alias kudu_build_dynclang='kudu_make_and_test_func DYNCLANG'
alias kudu_build_clang='kudu_make_and_test_func CLANGDEBUG'
alias kudu_build_asan='kudu_make_and_test_func ASAN'
alias kudu_build_asandebug='kudu_make_and_test_func ASANDEBUG'
alias kudu_build_tsan='kudu_make_and_test_func TSAN'
alias kudu_build_tsandebug='kudu_make_and_test_func TSANDEBUG'
alias kudu_build_client='kudu_make_and_test_func CLIENT'
alias kudu_build_coverage='kudu_make_and_test_func COVERAGE; (set -x; lcov --capture --directory src --output-file coverage.info && genhtml coverage.info --output-directory out)'
alias kudu_build_heapcheck='kudu_make_and_test_func HEAPCHECK'
alias kudu_build_release='kudu_make_and_test_func RELEASE'
alias kudu_cmake='kudu_run_cmake_func DEBUG'
alias kudu_cmake_dyn='kudu_run_cmake_func DYNDEBUG'
alias kudu_cmake_dynclang='kudu_run_cmake_func DYNCLANG'
alias kudu_cmake_clang='kudu_run_cmake_func CLANGDEBUG'
alias kudu_cmake_asan='kudu_run_cmake_func ASAN'
alias kudu_cmake_asandebug='kudu_run_cmake_func ASANDEBUG'
alias kudu_cmake_coverage='kudu_run_cmake_func COVERAGE'
alias kudu_cmake_tsan='kudu_run_cmake_func TSAN'
alias kudu_cmake_tsandebug='kudu_run_cmake_func TSANDEBUG'
alias kudu_cmake_client='kudu_run_cmake_func CLIENT'
alias kudu_cmake_release='kudu_run_cmake_func RELEASE'
alias kbt='rm -rf /tmp/kudutest-1000 && date && time $DEVTOOLSET $CMAKE_MAKE_PROG -j${NUM_PROCS_MINUS_ONE} $NINJA_OPTS && ( export TSAN_OPTIONS="$TSAN_OPTIONS second_deadlock_stack=1 suppressions=$(pwd)/build-support/tsan-suppressions.txt history_size=7 external_symbolizer_path=$LLVM_SYMBOLIZER"; unset GLOG_colorlogtostderr; date; time ctest -j${NUM_PROCS_MINUS_ONE}); alert "kbt exited with return code=$?"'
alias skbt='rm -rf /tmp/kudutest-1000 && date && time $DEVTOOLSET $CMAKE_MAKE_PROG -j${NUM_PROCS_MINUS_ONE} $NINJA_OPTS && ( export KUDU_ALLOW_SLOW_TESTS=1; export TSAN_OPTIONS="$TSAN_OPTIONS second_deadlock_stack=1 suppressions=$(pwd)/build-support/tsan-suppressions.txt history_size=7 external_symbolizer_path=$LLVM_SYMBOLIZER"; unset GLOG_colorlogtostderr; date; time ctest -j${NUM_PROCS_MINUS_ONE}); alert "skbt exited with return code=$?"'
#alias hkbt='rm -rf /tmp/kudutest-1000 && kudu_build_func HEAPCHECK && ( export HEAPCHECK=normal; export KUDU_ALLOW_SLOW_TESTS=1; export TSAN_OPTIONS="$TSAN_OPTIONS second_deadlock_stack=1 suppressions=$(pwd)/build-support/tsan-suppressions.txt history_size=7 external_symbolizer_path=$LLVM_SYMBOLIZER"; date; time ctest -j${NUM_PROCS_MINUS_ONE}); alert "hkbt exited with return code=$?"'
ktt_func() {
if [ -z "$1" ]; then
echo "Must specify test name"
return 1
fi
(
TESTNAME=$1
shift
echo "KUDU_ALLOW_SLOW_TESTS=$KUDU_ALLOW_SLOW_TESTS"
export TSAN_OPTIONS="$TSAN_OPTIONS second_deadlock_stack=1 suppressions=$(pwd)/../../build-support/tsan-suppressions.txt history_size=7 external_symbolizer_path=$LLVM_SYMBOLIZER"
echo "TSAN_OPTIONS=$TSAN_OPTIONS"
date
set -x
time ./bin/$TESTNAME $*
RETCODE=$?
set +x
date
# set $? to nonzero for alert()
if [[ $RETCODE == 0 ]]; then
/bin/true
else
/bin/false
fi
alert "$TESTNAME exited with return code=$RETCODE"
return $RETCODE
)
}
sktt_func() {
(
export KUDU_ALLOW_SLOW_TESTS=1
ktt_func $*
)
}
hktt_func() {
(
export HEAPCHECK=normal
sktt_func $*
)
}
kbtt_func() {
TESTNAME=$1
if [ -z "$TESTNAME" ]; then
echo "Must specify test name"
return 1
fi
(
date
set -ex
time $DEVTOOLSET $CMAKE_MAKE_PROG -j${NUM_PROCS_MINUS_ONE} $NINJA_OPTS $1
set +ex
date
ktt_func $*
)
}
cbtt_func() {
TESTNAME=$1
if [ -z "$TESTNAME" ]; then
echo "Must specify test name"
return 1
fi
(
unset GLOG_colorlogtostderr # avoid ANSI color garbage in the logs
date
set -x
time $DEVTOOLSET $CMAKE_MAKE_PROG -j${NUM_PROCS_MINUS_ONE} $NINJA_OPTS $TESTNAME || return $?
date
time ../../build-support/run-test.sh ./bin/$TESTNAME $@
RETCODE=$?
set +x
date
# set $? to nonzero for alert()
if [[ $RETCODE == 0 ]]; then
/bin/true
else
/bin/false
fi
alert "$TESTNAME exited with return code=$RETCODE"
return $RETCODE
)
}
scbtt_func() {
(
export KUDU_ALLOW_SLOW_TESTS=1
cbtt_func $*
)
}
skbtt_func() {
(
export KUDU_ALLOW_SLOW_TESTS=1
kbtt_func $*
)
}
hkbtt_func() {
(
export HEAPCHECK=normal
skbtt_func $*
)
}
gdbtt_func() {
if [ -z "$1" ]; then
echo "Must specify test name"
return 1
fi
(
export KUDU_ALLOW_SLOW_TESTS=1
export ASAN_OPTIONS=abort_on_error=1
TESTNAME=$1
echo "KUDU_ALLOW_SLOW_TESTS=$KUDU_ALLOW_SLOW_TESTS"
export TSAN_OPTIONS="$TSAN_OPTIONS second_deadlock_stack=1 suppressions=$(pwd)/../../build-support/tsan-suppressions.txt history_size=7 external_symbolizer_path=$LLVM_SYMBOLIZER"
echo "TSAN_OPTIONS=$TSAN_OPTIONS"
shift
date
set -e
set -x
time $DEVTOOLSET $CMAKE_MAKE_PROG -j${NUM_PROCS_MINUS_ONE} $NINJA_OPTS $TESTNAME
date
GDB=$(which gdb)
eval "$GDB $LOCAL_GDB_ARGS --args ./bin/$TESTNAME --gtest_break_on_failure $*"
)
}
# TSAN-compatible GDB
tsgdbtt_func() {
(
export LOCAL_GDB_ARGS="-ex 'set disable-randomization off' -ex 'b __tsan::PrintReport'"
gdbtt_func $*
)
}
klog_func() {
(
set -x
vim ./test-logs/$1.txt
)
}
alias kbf='$DEVTOOLSET $CMAKE_MAKE_PROG -j12 $NINJA_OPTS' # kudu-build-fast
alias ktt=ktt_func
alias sktt=sktt_func
alias hktt=hktt_func
alias kbtt=kbtt_func
alias cbtt=cbtt_func
alias scbtt=scbtt_func
alias skbtt=skbtt_func
alias hkbtt=hkbtt_func
alias gdbtt=gdbtt_func
alias tsgdbtt=tsgdbtt_func
alias readmes='find src/ -type f | egrep "README|\.txt$" | egrep -v "CMake|CTest" | grep -v \.swp'
alias perfstat='perf stat -d -e task-clock -e context-switches -e cpu-migrations -e page-faults -e cycles -e instructions -e branches -e branch-misses -e bus-cycles -e stalled-cycles-frontend -e stalled-cycles-backend -e ref-cycles -e context-switches -e L1-icache-loads -e L1-icache-load-misses -e L1-dcache-loads -e L1-dcache-load-misses -e dTLB-loads -e dTLB-load-misses -e iTLB-loads -e iTLB-load-misses -e branch-loads -e branch-load-misses -e cache-misses'
alias kudu_buildinfo="egrep 'CMAKE_BUILD_TYPE|KUDU_USE_' CMakeCache.txt | perl -pe 's/:\w+//'"
alias klog=klog_func
alias heapcheck='set -x; export HEAPCHECK=normal; export LD_BIND_NOW=1; set +x'
alias n='$DEVTOOLSET $CMAKE_MAKE_PROG'
alias cls='printf "\033c"'
alias pyhttpd='python -m SimpleHTTPServer'
alias tl="vim ~/todo-list.txt"
# Easy command to run for backups.
alias backup_homedir="mountpoint /media/mpercy/mpercy-backup && rsync -avz /home/mpercy /media/mpercy/mpercy-backup/root/home/"
# Rebase current git branch on master.
rebase_updated_branch() {
local base_branch=$1
(
if [ -z "$base_branch" ]; then
echo "Error: Must specify a branch to rebase onto"
return 1
fi
set -xe
if cur_branch=$(git symbolic-ref --short -q HEAD); then
update $base_branch
git checkout $cur_branch
git rebase $base_branch
else
echo "Error: Not currently on any branch"
return 1
fi
)
}
alias rebase_updated_master='rebase_updated_branch master'
alias rebase_updated_trunk='rebase_updated_branch trunk'
do_ntp_reset() {
NTP_SERVER=pool.ntp.org
set -x
sudo service ntp stop || return
sudo ntpdate "$NTP_SERVER" || return
sudo service ntp start || return
set +x
}
alias ntp-reset=do_ntp_reset
alias gist='gist-paste -po'
alias md='pandoc -f markdown_github -t html'
alias nm-restart='sudo service network-manager restart'
alias bt-restart='sudo service bluetooth restart'
alias bootstrap_vundle='[ ! -e ~/.vim/bundle/Vundle.vim ] && git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim && vim +PluginInstall +qall'
# For Flume contributors.
git_reset_author() {
AUTHOR=$1
if [ -z "$AUTHOR" ]; then
echo "Error: Must specify author"
return
fi
set -ex
git commit --amend --no-edit --author="$AUTHOR"
git log -n1
set +ex
}
alias git_reset_author_lior='git_reset_author "Lior Zeno <liorzino@gmail.com>"'
alias git_reset_author_denes='git_reset_author "Denes Arvay <denes@cloudera.com>"'
alias git_reset_author_donat='git_reset_author "Bessenyei Balázs Donát <bessbd@cloudera.com>"'
alias git_reset_author_jholoman='git_reset_author "Jeff Holoman <jeff.holoman@gmail.com>"'
alias git_reset_author_tinawenqiao='git_reset_author "wenqiao <315524513@qq.com>"'
alias git_reset_author_granthenke='git_reset_author "Grant Henke <granthenke@gmail.com>"'
alias git_reset_author_sati='git_reset_author "Attila Simon <sati@cloudera.com>"'
# TODO: shouldn't this get sourced by the shell automatically somehow anyway?
. ~/.bash_completions