Beispiel #1
0
func TestList(t *testing.T) {
	// ts := httptest.NewServer(ListBook)
	// fmt.Println(ts.G("/"))

	ts := httptest.NewServer(ListChapter)
	fmt.Println(ts.G("?id=%v", 1))
	fmt.Println(ts.G("?id=%v", 100))
}
Beispiel #2
0
func TestFFCM(t *testing.T) {
	runtime.GOMAXPROCS(util.CPU())
	//
	//
	//
	util.Exec("rm", "-f", "xx_*")
	var fcfg_s = util.NewFcfg3()
	fcfg_s.InitWithFilePath2("ffcm_s.properties", true)

	var sh = &dtcm_s_h{cw: make(chan int, 100)}
	var err error
	go func() {
		err := InitDtcmS(fcfg_s, dtm.MemDbc, sh)
		if err != nil {
			t.Error(err.Error())
			return
		}
		err = RunFFCM_S_V(fcfg_s)
		if err != nil {
			t.Error(err.Error())
			return
		}
	}()
	fmt.Println("xxx->")
	time.Sleep(1 * time.Second)
	go RunFFCM_C("ffcm_c.properties")
	time.Sleep(1 * time.Second)
	fmt.Println("xxxx--->a")
	err = SRV.AddTask("xx.mp4", "xx.mp4")
	if err != nil {
		t.Error(err.Error())
		return
	}
	fmt.Println("xxxx--->b")
	fmt.Println("xxxx--->c")
	<-sh.cw
	<-sh.cw
	util.Exec("rm", "-f", "xx_*")
	at_ts := httptest.NewServer(SRV.AddTaskH)
	res, err := at_ts.G2("/addTask?args=%v,%v", "xx.mp4", "xx_x")
	if res.IntVal("code") != 0 {
		t.Error("error")
		return
	}
	<-sh.cw
	<-sh.cw
	var vproc = SRV.AbsL[0].(*AbsV)
	if _, _, _, err = vproc.Build(SRV, "xkkd", nil, "xdds"); err == nil {
		t.Error("error")
		return
	}
	ts := httptest.NewServer2(NewVideoProc(CLIENT))
	ts.PostN("?tid=%v", "text/plain", bytes.NewBufferString(`
		`), "xxx")
	ts.PostN("?tid=%v&duration=1111", "text/plain", bytes.NewBufferString(`
		xx=
		progress=end
		`), "xxx")
	fmt.Println("xxxx--->d")
	//
	util.Exec("cp", "xx.mp4", "xx_mm")
	SRV.AddTask("xx_mm")
	SRV.AddTask("ffcm.sh")
	//
	// RunFFCM_S("ffcm_s.properties", dtm.MemDbc, sh)
	// RunFFCM_S_V(nil, dtm.MemDbc, sh)
	RunFFCM_C("ffcm_c.properties")
	//
	// StopFFCM_C()
	// StopFFCM_S()
	time.Sleep(2 * time.Second)
	//
	// StopFFCM_C()
	// StopFFCM_S()
	//
	res, err = at_ts.G2("/addTask?src=%v", "sfsd")
	if res.IntVal("code") == 0 {
		t.Error("error")
		return
	}
	CLIENT.Stop()
	SRV.Close()
	SRV = nil
	CLIENT = nil
	RunFFCM_S_V(nil)
	//
	//

	util.Exec("rm", "-f", "xx_*")
}