initial commit
This commit is contained in:
16
third_party/libhv/scripts/check.sh
vendored
Executable file
16
third_party/libhv/scripts/check.sh
vendored
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd `dirname $0`; pwd)
|
||||
ROOT_DIR=${SCRIPT_DIR}/..
|
||||
cd ${ROOT_DIR}
|
||||
|
||||
bin/httpd -c etc/httpd.conf -s restart -d
|
||||
ps aux | grep httpd
|
||||
HTTPS=`netstat -atn | grep 8443 | wc -l`
|
||||
|
||||
bin/http_client_test
|
||||
bin/curl -v http://127.0.0.1:8080/
|
||||
if [ $HTTPS -gt 0 ]; then
|
||||
bin/curl -v https://127.0.0.1:8443/
|
||||
fi
|
||||
bin/wrk -c 100 -t 2 -d 10s http://127.0.0.1:8080/ping
|
||||
25
third_party/libhv/scripts/cmake_cross_compile.sh
vendored
Executable file
25
third_party/libhv/scripts/cmake_cross_compile.sh
vendored
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd `dirname $0`; pwd)
|
||||
ROOT_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
CROSS_COMPILE=$1
|
||||
else
|
||||
sudo apt install g++-arm-linux-gnueabi
|
||||
CROSS_COMPILE=arm-linux-gnueabi-
|
||||
fi
|
||||
echo CROSS_COMPILE=${CROSS_COMPILE}
|
||||
|
||||
cd ${ROOT_DIR}
|
||||
. scripts/toolchain.sh export ${CROSS_COMPILE}
|
||||
BUILD_DIR=build/${HV_TARGET_OS}/${HV_TARGET_ARCH}
|
||||
echo BUILD_DIR=${BUILD_DIR}
|
||||
mkdir -p ${BUILD_DIR}
|
||||
cd ${BUILD_DIR}
|
||||
cmake ../../.. -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_SYSTEM_NAME=$HV_TARGET_OS -DCMAKE_SYSTEM_PROCESSOR=$HV_TARGET_ARCH
|
||||
make libhv libhv_static
|
||||
cd ${ROOT_DIR}
|
||||
. scripts/toolchain.sh unset ${CROSS_COMPILE}
|
||||
|
||||
echo 'Completed => ${BUILD_DIR}'
|
||||
89
third_party/libhv/scripts/consul.py
vendored
Executable file
89
third_party/libhv/scripts/consul.py
vendored
Executable file
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import json
|
||||
import requests
|
||||
|
||||
headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36',
|
||||
'Cache-Control': 'no-cache',
|
||||
'Accpet': '*/*',
|
||||
'Content-Type': 'application/json'}
|
||||
|
||||
_node = {'ip': '127.0.0.1', 'port': 8500}
|
||||
|
||||
def gen_ServiceID(service_name, service_ip, service_port):
|
||||
return service_name + '-' + service_ip + ':' + str(service_port)
|
||||
|
||||
def register_service(service_name, service_ip, service_port , node=_node):
|
||||
service = {}
|
||||
service['Name'] = service_name
|
||||
service['Address'] = service_ip
|
||||
service['Port'] = service_port
|
||||
service['ID'] = gen_ServiceID(service_name, service_ip, service_port)
|
||||
check = {}
|
||||
check['TCP'] = service['Address'] + ':' + str(service['Port'])
|
||||
check['Interval'] = '10s'
|
||||
check['DeregisterCriticalServiceAfter'] = '30s'
|
||||
service['Check'] = check
|
||||
data = json.dumps(service)
|
||||
url = 'http://' + node['ip'] + ':' + str(node['port'])
|
||||
url += '/v1/agent/service/register'
|
||||
try:
|
||||
res = requests.put(url=url, headers=headers, data=data)
|
||||
return res.status_code == 200 and len(res.content) == 0
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return False
|
||||
|
||||
def deregister_service(ServiceID, node=_node):
|
||||
url = 'http://' + node['ip'] + ':' + str(node['port'])
|
||||
url += '/v1/agent/service/deregister/'
|
||||
url += ServiceID
|
||||
try:
|
||||
res = requests.put(url=url, headers=headers)
|
||||
return res.status_code == 200 and len(res.content) == 0
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return False
|
||||
|
||||
def discover_service(service_name, node=_node):
|
||||
url = 'http://' + node['ip'] + ':' + str(node['port'])
|
||||
url += '/v1/catalog/service/'
|
||||
url += service_name
|
||||
try:
|
||||
res = requests.get(url=url, headers=headers)
|
||||
return res.content
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return 'false'
|
||||
|
||||
def main():
|
||||
print(sys.argv)
|
||||
if len(sys.argv) < 4:
|
||||
print('Usage: cmd service_name service_ip service_port node_ip node_port')
|
||||
return
|
||||
service_name = sys.argv[1]
|
||||
service_ip = sys.argv[2]
|
||||
service_port = int(sys.argv[3])
|
||||
if len(sys.argv) >= 5:
|
||||
_node['ip'] = sys.argv[4]
|
||||
_node['port'] = int(sys.argv[5])
|
||||
ServiceID = gen_ServiceID(service_name, service_ip, service_port)
|
||||
if register_service(service_name, service_ip, service_port):
|
||||
print('register_service [%s] succeed!' % (ServiceID))
|
||||
else:
|
||||
print('register_service failed!')
|
||||
|
||||
print(discover_service(service_name))
|
||||
|
||||
'''
|
||||
if deregister_service(ServiceID):
|
||||
print('deregister_service [%s] succeed!' % (ServiceID))
|
||||
else:
|
||||
print('deregister_service failed')
|
||||
|
||||
print(discover_service(service_name))
|
||||
'''
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
25
third_party/libhv/scripts/consul_agent.sh
vendored
Executable file
25
third_party/libhv/scripts/consul_agent.sh
vendored
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
rm -r consul
|
||||
rm nohup.out
|
||||
mkdir consul
|
||||
|
||||
print_help() {
|
||||
cat <<EOF
|
||||
Usage:cmd bind_ip
|
||||
|
||||
example:
|
||||
./consul_agent.sh 192.168.1.123
|
||||
EOF
|
||||
}
|
||||
|
||||
main() {
|
||||
if [ $# -lt 1 ]; then
|
||||
print_help
|
||||
return
|
||||
fi
|
||||
bind_ip=$1
|
||||
nohup consul agent -server -ui -bootstrap-expect=1 -node=s1 -bind=${bind_ip} -client=0.0.0.0 -data-dir=/var/lib/consul -pid-file=consul/consul.pid -log-file=consul/consul.log &
|
||||
}
|
||||
|
||||
main $@
|
||||
19
third_party/libhv/scripts/coredump.sh
vendored
Executable file
19
third_party/libhv/scripts/coredump.sh
vendored
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
print_conf() {
|
||||
echo /proc/sys/kernel/core_uses_pid
|
||||
cat /proc/sys/kernel/core_uses_pid
|
||||
echo /proc/sys/kernel/core_pattern
|
||||
cat /proc/sys/kernel/core_pattern
|
||||
echo /proc/sys/fs/suid_dumpable
|
||||
cat /proc/sys/fs/suid_dumpable
|
||||
}
|
||||
|
||||
print_conf
|
||||
echo "1" > /proc/sys/kernel/core_uses_pid
|
||||
echo "/tmp/core-%e-%p-%t" > /proc/sys/kernel/core_pattern
|
||||
echo "1" > /proc/sys/fs/suid_dumpable
|
||||
print_conf
|
||||
|
||||
ulimit -c unlimited
|
||||
ulimit -a
|
||||
13
third_party/libhv/scripts/create_repo.sh
vendored
Executable file
13
third_party/libhv/scripts/create_repo.sh
vendored
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir -p include lib src bin doc etc 3rd/include 3rd/lib dist
|
||||
touch README.md BUILD.md RELEASE.md CHANGELOG.md Makefile .gitignore
|
||||
git init
|
||||
|
||||
# personal
|
||||
git submodule add https://github.com/ithewei/libhv.git src/hv
|
||||
cp src/hv/.gitignore .
|
||||
cp src/hv/.clang-format .
|
||||
cp src/hv/Makefile .
|
||||
cp -r src/hv/etc/* etc
|
||||
cp src/hv/examples/hmain_test.cpp src/main.cpp
|
||||
9
third_party/libhv/scripts/libhv.cmake
vendored
Executable file
9
third_party/libhv/scripts/libhv.cmake
vendored
Executable file
@@ -0,0 +1,9 @@
|
||||
set(CMAKE_C_COMPILER $CC)
|
||||
set(CMAKE_CXX_COMPILER $CXX)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME $HV_TARGET_OS)
|
||||
set(CMAKE_SYSTEM_PROCESSOR $HV_TARGET_ARCH)
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-D_WIN32_WINNT=0x600)
|
||||
endif()
|
||||
311
third_party/libhv/scripts/shini.sh
vendored
Executable file
311
third_party/libhv/scripts/shini.sh
vendored
Executable file
@@ -0,0 +1,311 @@
|
||||
# shini - compatible INI library for sh
|
||||
#
|
||||
# This code is released freely under the MIT license - see the shipped LICENSE document.
|
||||
# For the latest version etc, please see https://github.com/wallyhall/shini
|
||||
#
|
||||
|
||||
# Solely for the purpose of portable performance, this script breaks good practice to
|
||||
# avoid forking subshells. One such good practice is avoiding global variables.
|
||||
# This variable is used to carry non-numeric results from functions to the caller.
|
||||
# Alternatively an echo and "$(...)" approach could be used, but is significantly slower.
|
||||
|
||||
shini_setup()
|
||||
{
|
||||
if [ -n "$ZSH_VERSION" ]; then
|
||||
RESTORE_OPTS=$(set +o)
|
||||
# Enable BASH_REMATCH for zsh
|
||||
setopt KSH_ARRAYS BASH_REMATCH
|
||||
fi
|
||||
}
|
||||
|
||||
shini_teardown()
|
||||
{
|
||||
[ -n "$ZSH_VERSION" ] && eval "$RESTORE_OPTS"
|
||||
}
|
||||
|
||||
shini_function_exists()
|
||||
{
|
||||
type "$1" > /dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
|
||||
shini_regex_match()
|
||||
{
|
||||
# $KSH_VERSION (I'm told) only exists on ksh 93 and above, which supports regex matching.
|
||||
if [ -n "$BASH_VERSINFO" ] && [ "$BASH_VERSINFO" -ge 3 ] || \
|
||||
[ -n "$ZSH_VERSION" ] || \
|
||||
[ -n "$KSH_VERSION" ]; then
|
||||
[[ "$1" =~ $2 ]] && return 0 || return 1
|
||||
fi
|
||||
|
||||
printf '%s' "$1" | grep -qe "$2"
|
||||
return $?
|
||||
}
|
||||
|
||||
shini_regex_replace()
|
||||
{
|
||||
if [ -n "$BASH_VERSINFO" ] && [ "${BASH_VERSINFO}" -ge 3 ] || \
|
||||
[ -n "$ZSH_VERSION" ]; then
|
||||
[[ "$1" =~ $2 ]] && shini_retval=${BASH_REMATCH[1]} || shini_retval="$1"
|
||||
return 0
|
||||
fi
|
||||
|
||||
shini_retval="$(printf '%s' "$1" | sed -E "s/$2/\1/")" # If you have isses on older systems,
|
||||
# it may be the non-newer POSIX compliant sed.
|
||||
# -E should be enabling extended regex mode portably.
|
||||
}
|
||||
|
||||
# @param inifile Filename of INI file to parse
|
||||
# @param postfix Function postfix for callbacks (optional)
|
||||
# @param extra Extra argument for callbacks (optional)
|
||||
shini_parse()
|
||||
{
|
||||
shini_parse_section "$1" '' "$2" "$3" "$4" "$5"
|
||||
}
|
||||
|
||||
# @param inifile Filename of INI file to parse
|
||||
# @param section Section to parse (or empty string for entire file)
|
||||
# @param postfix Function postfix for callbacks (optional)
|
||||
# @param extra Extra argument for callbacks (optional)
|
||||
shini_parse_section()
|
||||
{
|
||||
shini_setup
|
||||
# ********
|
||||
|
||||
RX_KEY='[a-zA-Z0-9_\-\.]'
|
||||
RX_VALUE="[^;\"]"
|
||||
RX_SECTION='[a-zA-Z0-9_\-]'
|
||||
RX_WS='[ ]'
|
||||
RX_QUOTE='"'
|
||||
RX_HEX='[0-9A-F]'
|
||||
POSTFIX=''
|
||||
SKIP_TO_SECTION=''
|
||||
EXTRA1=''
|
||||
EXTRA2=''
|
||||
EXTRA3=''
|
||||
SECTION_FOUND=-1
|
||||
|
||||
if [ $# -ge 2 ] && [ ! -z "$2" ]; then
|
||||
SKIP_TO_SECTION="$2"
|
||||
fi
|
||||
|
||||
if [ $# -ge 3 ] && [ ! -z "$3" ]; then
|
||||
POSTFIX="_$3"
|
||||
fi
|
||||
|
||||
if [ $# -ge 4 ] && ! [ -z "$4" ]; then
|
||||
EXTRA1="$4"
|
||||
fi
|
||||
|
||||
if [ $# -ge 5 ] && [ ! -z "$5" ]; then
|
||||
EXTRA2="$5"
|
||||
fi
|
||||
|
||||
if [ $# -ge 6 ] && [ ! -z "$6" ]; then
|
||||
EXTRA3="$6"
|
||||
fi
|
||||
|
||||
if ! shini_function_exists "__shini_parsed${POSTFIX}"; then
|
||||
printf 'shini: __shini_parsed%s function not declared.\n' "${POSTFIX}" 1>&2
|
||||
exit 255
|
||||
fi
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
if shini_function_exists "__shini_no_file_passed{$POSTFIX}"; then
|
||||
"__shini_no_file_passed${POSTFIX}" "$EXTRA1" "$EXTRA2" "$EXTRA3"
|
||||
else
|
||||
printf 'shini: Argument 1 needs to specify the INI file to parse.\n' 1>&2
|
||||
exit 254
|
||||
fi
|
||||
fi
|
||||
INI_FILE="$1"
|
||||
|
||||
if [ ! -r "$INI_FILE" ]; then
|
||||
if shini_function_exists "__shini_file_unreadable${POSTFIX}"; then
|
||||
"__shini_file_unreadable${POSTFIX}" "$INI_FILE" "$EXTRA1" "$EXTRA2" "$EXTRA3"
|
||||
else
|
||||
printf 'shini: Unable to read INI file:\n `%s`\n' "$INI_FILE" 1>&2
|
||||
exit 253
|
||||
fi
|
||||
fi
|
||||
|
||||
# Iterate INI file line by line
|
||||
LINE_NUM=0
|
||||
SECTION=''
|
||||
while read LINE || [ -n "$LINE" ]; do # -n $LINE catches final line if not empty
|
||||
# Check for new sections
|
||||
if shini_regex_match "$LINE" "^${RX_WS}*\[${RX_SECTION}${RX_SECTION}*\]${RX_WS}*$"; then
|
||||
shini_regex_replace "$LINE" "^${RX_WS}*\[(${RX_SECTION}${RX_SECTION}*)\]${RX_WS}*$" "\1"
|
||||
SECTION=$shini_retval
|
||||
|
||||
if [ "$SKIP_TO_SECTION" != '' ]; then
|
||||
# stop once specific section is finished
|
||||
[ $SECTION_FOUND -eq 0 ] && break;
|
||||
|
||||
# mark the specified section as found
|
||||
[ "$SKIP_TO_SECTION" = "$SECTION" ] && SECTION_FOUND=0;
|
||||
fi
|
||||
|
||||
if shini_function_exists "__shini_parsed_section${POSTFIX}"; then
|
||||
"__shini_parsed_section${POSTFIX}" "$SECTION" "$EXTRA1" "$EXTRA2" "$EXTRA3"
|
||||
fi
|
||||
|
||||
LINE_NUM=$((LINE_NUM+1))
|
||||
continue
|
||||
fi
|
||||
|
||||
# Skip over sections we don't care about, if a specific section was specified
|
||||
[ "$SKIP_TO_SECTION" != '' ] && [ $SECTION_FOUND -ne 0 ] && LINE_NUM=$((LINE_NUM+1)) && continue;
|
||||
|
||||
# Check for new values
|
||||
if shini_regex_match "$LINE" "^${RX_WS}*${RX_KEY}${RX_KEY}*${RX_WS}*="; then
|
||||
shini_regex_replace "$LINE" "^${RX_WS}*(${RX_KEY}${RX_KEY}*)${RX_WS}*=.*$"
|
||||
KEY=$shini_retval
|
||||
|
||||
shini_regex_replace "$LINE" "^${RX_WS}*${RX_KEY}${RX_KEY}*${RX_WS}*=${RX_WS}*${RX_QUOTE}{0,1}(${RX_VALUE}*)${RX_QUOTE}{0,1}(${RX_WS}*\;.*)*$"
|
||||
VALUE=$shini_retval
|
||||
|
||||
if shini_regex_match "$LINE" "^0x${RX_HEX}${RX_HEX}*$"; then
|
||||
VALUE=$(printf '%d' "$VALUE")
|
||||
fi
|
||||
|
||||
"__shini_parsed${POSTFIX}" "$SECTION" "$KEY" "$VALUE" "$EXTRA1" "$EXTRA2" "$EXTRA3"
|
||||
|
||||
if shini_function_exists "__shini_parsed_comment${POSTFIX}"; then
|
||||
if shini_regex_match "$LINE" ";"; then
|
||||
shini_regex_replace "$LINE" "^.*\;(.*)$"
|
||||
COMMENT=$shini_retval
|
||||
|
||||
"__shini_parsed_comment${POSTFIX}" "$COMMENT" "$EXTRA1" "$EXTRA2" "$EXTRA3"
|
||||
fi
|
||||
fi
|
||||
|
||||
LINE_NUM=$((LINE_NUM+1))
|
||||
continue
|
||||
fi
|
||||
|
||||
# Announce parse errors
|
||||
if [ "$LINE" != '' ] &&
|
||||
! shini_regex_match "$LINE" "^${RX_WS}*;.*$" &&
|
||||
! shini_regex_match "$LINE" "^${RX_WS}*$"; then
|
||||
if shini_function_exists "__shini_parse_error${POSTFIX}"; then
|
||||
"__shini_parse_error${POSTFIX}" $LINE_NUM "$LINE" "$EXTRA1" "$EXTRA2" "$EXTRA3"
|
||||
else
|
||||
printf 'shini: Unable to parse line %d:\n `%s`\n' $LINE_NUM "$LINE"
|
||||
fi
|
||||
fi
|
||||
|
||||
LINE_NUM=$((LINE_NUM+1))
|
||||
done < "$INI_FILE"
|
||||
|
||||
# ********
|
||||
shini_teardown
|
||||
}
|
||||
|
||||
# @param inifile Filename of INI file to write to
|
||||
# @param section Section of INI file to write to
|
||||
# @param variable Variable name to add/update/delete
|
||||
# @param value Value to add/update, do not specify to delete
|
||||
shini_write()
|
||||
{
|
||||
shini_setup
|
||||
# ********
|
||||
|
||||
# This is not yet optimised (early write support only) -
|
||||
# We actually re-parse the entire file, looking for the location in which to
|
||||
# write the new value, writing out everything we parse as-is meanwhile.
|
||||
|
||||
# Declare the following if you want particular behaviour (like skipping
|
||||
# broken INI file content or handling an unreadable file etc).
|
||||
# __shini_no_file_passed__writer()
|
||||
# __shini_file_unreadable__writer()
|
||||
# __shini_parse_error__writer()
|
||||
|
||||
# Writer callbacks, used for writing the INI file content
|
||||
__shini_parsed_section__writer()
|
||||
{
|
||||
# Validate the last section wasn't the target section
|
||||
if [ "$LAST_SECTION" = "$WRITE_SECTION" ]; then
|
||||
# If it was, and the value wasn't written already, write it
|
||||
if [ $VALUE_WRITTEN -eq 0 ]; then
|
||||
printf "\n%s=%s" "$WRITE_KEY" "$WRITE_VALUE" >> "$INI_FILE_TEMP"
|
||||
VALUE_WRITTEN=1
|
||||
fi
|
||||
fi
|
||||
printf "\n[%s]" "$1" >> "$INI_FILE_TEMP"
|
||||
|
||||
LAST_SECTION="$1"
|
||||
}
|
||||
|
||||
__shini_parsed_comment__writer()
|
||||
{
|
||||
printf ";%s" "$1" >> "$INI_FILE_TEMP"
|
||||
}
|
||||
|
||||
__shini_parsed__writer()
|
||||
{
|
||||
if [ "$1" = "$WRITE_SECTION" ]; then
|
||||
if [ "$2" = "$WRITE_KEY" ]; then
|
||||
if [ ! -z "$WRITE_VALUE" ]; then
|
||||
printf "\n%s=%s" "$WRITE_KEY" "$WRITE_VALUE" >> "$INI_FILE_TEMP"
|
||||
fi
|
||||
VALUE_WRITTEN=1
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
printf "\n%s=%s" "$2" "$3" >> "$INI_FILE_TEMP"
|
||||
}
|
||||
|
||||
if [ $# -lt 3 ]; then
|
||||
if shini_function_exists "__shini_no_file_passed"; then
|
||||
__shini_no_file_passed
|
||||
else
|
||||
printf 'shini: Argument 1 needs to specify the INI file to write.\n' 1>&2
|
||||
exit 254
|
||||
fi
|
||||
fi
|
||||
|
||||
INI_FILE="$1"
|
||||
INI_FILE_TEMP="$(mktemp -t shini_XXXXXX)"
|
||||
|
||||
WRITE_SECTION="$2"
|
||||
WRITE_KEY="$3"
|
||||
WRITE_VALUE="$4"
|
||||
LAST_SECTION=""
|
||||
VALUE_WRITTEN=0
|
||||
|
||||
shini_parse "$1" "_writer" "$2" "$3" "$4"
|
||||
# Still not written out yet
|
||||
if [ $VALUE_WRITTEN -eq 0 ]; then
|
||||
# Check if final existing section was target one, add it if not
|
||||
if [ "$LAST_SECTION" != "$WRITE_SECTION" ]; then
|
||||
printf "\n[%s]" "$WRITE_SECTION" >> "$INI_FILE_TEMP"
|
||||
fi
|
||||
# Write value at end of file
|
||||
printf "\n%s=%s" "$WRITE_KEY" "$WRITE_VALUE" >> "$INI_FILE_TEMP"
|
||||
fi
|
||||
|
||||
mv "$INI_FILE_TEMP" "$INI_FILE"
|
||||
|
||||
# ********
|
||||
shini_teardown
|
||||
}
|
||||
|
||||
# default usage
|
||||
__shini_parsed()
|
||||
{
|
||||
if [[ $2 != *\$* ]] && [[ $3 != *\$* ]]; then
|
||||
eval $2=$3
|
||||
fi
|
||||
}
|
||||
|
||||
__shini_parse_error()
|
||||
{
|
||||
error_line=$1
|
||||
}
|
||||
|
||||
__shini_parse_error__writer()
|
||||
{
|
||||
error_line=$1
|
||||
}
|
||||
40
third_party/libhv/scripts/test-coverage.sh
vendored
Executable file
40
third_party/libhv/scripts/test-coverage.sh
vendored
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd `dirname $0`; pwd)
|
||||
ROOT_DIR=${SCRIPT_DIR}/..
|
||||
cd ${ROOT_DIR}
|
||||
|
||||
bin/httpd -c etc/httpd.conf -s restart -d
|
||||
|
||||
bin/ls
|
||||
bin/date
|
||||
bin/ifconfig
|
||||
bin/mkdir_p 123/456
|
||||
bin/rmdir_p 123/456
|
||||
|
||||
bin/defer_test
|
||||
bin/hstring_test
|
||||
bin/hpath_test
|
||||
bin/hatomic_test
|
||||
bin/hatomic_cpp_test
|
||||
bin/hmutex_test
|
||||
bin/socketpair_test
|
||||
bin/threadpool_test
|
||||
bin/objectpool_test
|
||||
|
||||
bin/curl -v localhost:8080
|
||||
bin/curl -v localhost:8080/ping
|
||||
bin/curl -v localhost:8080/echo -d "hello,world!"
|
||||
bin/curl -v localhost:8080/query?page_no=1\&page_size=10
|
||||
bin/curl -v localhost:8080/kv -H "Content-Type:application/x-www-form-urlencoded" -d 'user=admin&pswd=123456'
|
||||
bin/curl -v localhost:8080/json -H "Content-Type:application/json" -d '{"user":"admin","pswd":"123456"}'
|
||||
bin/curl -v localhost:8080/form -F "user=admin pswd=123456"
|
||||
bin/curl -v localhost:8080/upload -F "file=@LICENSE"
|
||||
bin/curl -v localhost:8080/test -H "Content-Type:application/x-www-form-urlencoded" -d 'bool=1&int=123&float=3.14&string=hello'
|
||||
bin/curl -v localhost:8080/test -H "Content-Type:application/json" -d '{"bool":true,"int":123,"float":3.14,"string":"hello"}'
|
||||
bin/curl -v localhost:8080/test -F 'bool=1 int=123 float=3.14 string=hello'
|
||||
bin/curl -v -X DELETE localhost:8080/group/test/user/123
|
||||
|
||||
bin/httpd -s stop
|
||||
|
||||
bin/htimer_test
|
||||
101
third_party/libhv/scripts/toolchain.sh
vendored
Executable file
101
third_party/libhv/scripts/toolchain.sh
vendored
Executable file
@@ -0,0 +1,101 @@
|
||||
#!/bin/bash
|
||||
|
||||
print_help() {
|
||||
cat <<EOF
|
||||
Usage: command
|
||||
|
||||
command:
|
||||
export CROSS_COMPILE
|
||||
unset
|
||||
|
||||
example:
|
||||
source ./toolchain.sh export arm-linux-androideabi
|
||||
source ./toolchain.sh unset
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
main() {
|
||||
if [ $# -lt 1 ]; then
|
||||
print_help
|
||||
return
|
||||
fi
|
||||
COMMAND=$1
|
||||
|
||||
if [ $COMMAND = "export" ]; then
|
||||
if [ $# -lt 2 ]; then
|
||||
print_help
|
||||
return
|
||||
fi
|
||||
CROSS_COMPILE=$2
|
||||
if [ ${CROSS_COMPILE:${#CROSS_COMPILE}-1:1} != "-" ]; then
|
||||
CROSS_COMPILE=${CROSS_COMPILE}-
|
||||
fi
|
||||
echo "CROSS_COMPILE=$CROSS_COMPILE"
|
||||
export CROSS_COMPILE=${CROSS_COMPILE}
|
||||
export CC=${CROSS_COMPILE}gcc
|
||||
export CXX=${CROSS_COMPILE}g++
|
||||
export AR=${CROSS_COMPILE}ar
|
||||
export AS=${CROSS_COMPILE}as
|
||||
export LD=${CROSS_COMPILE}ld
|
||||
export STRIP=${CROSS_COMPILE}strip
|
||||
export RANLIB=${CROSS_COMPILE}ranlib
|
||||
export NM=${CROSS_COMPILE}nm
|
||||
|
||||
HOST_OS=`uname -s`
|
||||
HOST_ARCH=`uname -m`
|
||||
TARGET_PLATFORM=`$CC -v 2>&1 | grep Target | sed 's/Target: //'`
|
||||
TARGET_ARCH=`echo $TARGET_PLATFORM | awk -F'-' '{print $1}'`
|
||||
|
||||
case $TARGET_PLATFORM in
|
||||
*mingw*) TARGET_OS=Windows ;;
|
||||
*android*) TARGET_OS=Android ;;
|
||||
*darwin*) TARGET_OS=Darwin ;;
|
||||
*) TARGET_OS=Linux ;;
|
||||
esac
|
||||
# TARGET_OS,TARGET_ARCH used by make
|
||||
export HV_HOST_OS=$HOST_OS
|
||||
export HV_HOST_ARCH=$HOST_ARCH
|
||||
export HV_TARGET_OS=$TARGET_OS
|
||||
export HV_TARGET_ARCH=$TARGET_ARCH
|
||||
export HOST=$TARGET_PLATFORM
|
||||
elif [ $COMMAND = "unset" ]; then
|
||||
unset CROSS_COMPILE
|
||||
unset CC
|
||||
unset CXX
|
||||
unset AR
|
||||
unset AS
|
||||
unset LD
|
||||
unset STRIP
|
||||
unset RANLIB
|
||||
unset NM
|
||||
|
||||
unset HOST_OS
|
||||
unset HOST_ARCH
|
||||
unset TARGET_OS
|
||||
unset TARGET_ARCH
|
||||
unset HOST
|
||||
else
|
||||
print_help
|
||||
return
|
||||
fi
|
||||
}
|
||||
|
||||
main $@
|
||||
echo "CC = $CC"
|
||||
echo "CXX = $CXX"
|
||||
if [ $CC ]; then
|
||||
CC_VERSION=`$CC --version 2>&1 | head -n 1`
|
||||
echo "$CC_VERSION"
|
||||
fi
|
||||
echo "AR = $AR"
|
||||
echo "AS = $AS"
|
||||
echo "LD = $LD"
|
||||
echo "STRIP = $STRIP"
|
||||
echo "RANLIB = $RANLIB"
|
||||
echo "NM = $NM"
|
||||
|
||||
echo "HV_HOST_OS = $HOST_OS"
|
||||
echo "HV_HOST_ARCH = $HOST_ARCH"
|
||||
echo "HV_TARGET_OS = $TARGET_OS"
|
||||
echo "HV_TARGET_ARCH = $TARGET_ARCH"
|
||||
30
third_party/libhv/scripts/unittest.sh
vendored
Executable file
30
third_party/libhv/scripts/unittest.sh
vendored
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd `dirname $0`; pwd)
|
||||
ROOT_DIR=${SCRIPT_DIR}/..
|
||||
cd ${ROOT_DIR}
|
||||
|
||||
bin/rbtree_test
|
||||
bin/hbase_test
|
||||
bin/date
|
||||
bin/ifconfig
|
||||
bin/mkdir_p 123/456
|
||||
bin/ls
|
||||
bin/rmdir_p 123/456
|
||||
|
||||
bin/base64
|
||||
bin/md5
|
||||
bin/sha1
|
||||
|
||||
bin/defer_test
|
||||
bin/hstring_test
|
||||
bin/hpath_test
|
||||
bin/hurl_test
|
||||
# bin/hatomic_test
|
||||
# bin/hatomic_cpp_test
|
||||
# bin/hthread_test
|
||||
# bin/hmutex_test
|
||||
bin/socketpair_test
|
||||
# bin/threadpool_test
|
||||
# bin/objectpool_test
|
||||
bin/sizeof_test
|
||||
18
third_party/libhv/scripts/websocket_server.py
vendored
Executable file
18
third_party/libhv/scripts/websocket_server.py
vendored
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# pip3 install websockets
|
||||
|
||||
import asyncio
|
||||
import websockets
|
||||
|
||||
async def echo(websocket):
|
||||
async for message in websocket:
|
||||
print(message)
|
||||
await websocket.send(message)
|
||||
|
||||
async def serve(port):
|
||||
async with websockets.serve(echo, "0.0.0.0", port):
|
||||
await asyncio.Future()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(serve(9999))
|
||||
Reference in New Issue
Block a user